导致0月份参数错误输出 [英] leading 0 in month parameter making wrong output
本文介绍了导致0月份参数错误输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
echo date(Ymd,mktime(0, 0,0,09,23,2013)); //输出2012-12-23
echo date(Ymd,mktime(0,0,0,9,23,2013)); //输出2013-09-23
解决方案
从 https://bugs.php.net/bug.php?id=55327 :
带前导0的数字是八进制数。 08是无效值。请参阅
http://php.net/integer
如果您使用带有 0
的数字前缀,则将该数字标记为 Octal 。八进制数字系统使用数字0到7.因此, 08
和 09
不存在,无效。
第二个声明是正确的,这是正确的方法:
echo date(Ymd,mktime(0,0,0,9,23,2013));
Why the leading zero in the month parameter making wrong output?
echo date("Y-m-d", mktime(0, 0, 0, 09, 23, 2013));//output 2012-12-23
echo date("Y-m-d", mktime(0, 0, 0, 9, 23, 2013));//output 2013-09-23
解决方案
From https://bugs.php.net/bug.php?id=55327:
Numbers with leading 0's are octal. 08 is an invalid value. See http://php.net/integer
If you prefix a number with a leading 0
, it marks the number as Octal. The octal numeral system uses the digits 0 to 7. So, 08
and 09
doesn't exist and are invalid.
The second statement is correct, and that's the correct method:
echo date("Y-m-d", mktime(0, 0, 0, 9, 23, 2013));
这篇关于导致0月份参数错误输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文