<code><?phpecho strftime("%G-%m-%d", time());//得到2015-12-31</code>
回复内容:
<code><?phpecho strftime("%G-%m-%d", time());//得到2015-12-31</code>
%G
不是公历历法的年,而是按照ISO-8601:1988
标准的年,是按周为单位计算的年
根据此种历法,每年第一个不少于4天
(周1是一周的第一天)的周,视作第一周,少于4天则整个周视作上一年的最后一周
<code>xelz's MacBook-Air: <em style="color:transparent">本@文来源[email protected]搞@^&代*@码网(</em><q>搞代gaodaima码</q>~/tmp [12:21:18]$ php -r 'error_reporting(0);echo strftime("%G-%V", strtotime("2014-12-28"))."\n";'2014-52xelz's MacBook-Air: ~/tmp [12:21:26]$ php -r 'error_reporting(0);echo strftime("%G-%V", strtotime("2014-12-29"))."\n";'2015-01</code>
获得年份,应该使用 %y
或者 %Y