开发者

strftime() not print chinese character "年“

开发者 https://www.devze.com 2023-01-18 10:15 出处:网络
If locale is set to zh_CN.ut8, and using strftime(\"%b %Y\", time()); It shows 9月2010 instead of 9月2010年。

If locale is set to zh_CN.ut8, and using strftime("%b %Y", time()); It shows 9月2010 instead of 9月2010年。 This is not correct in chinese date, the year character (年)should be display at the end of the numeric year. Is there a way to solve this problem? I know I can append the character manually, example:

strftime("%b %Y", time开发者_开发问答())."年"

but would like to know if there's a better way to solve it.


No better way. I use this

strftime('%Y年%m月%e日');


There is no better way. Prepare your dates with as few characters in them. Think of dates as numbers only. While you are able to output AM/PM, it's better to determine that on your own, for example. The reason for this is that it makes for cleaner and more intuitive code on your side.

0

精彩评论

暂无评论...
验证码 换一张
取 消