日期功能的奇怪行为 [英] Strange behavior of Date Function

查看:168
本文介绍了日期功能的奇怪行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天遇到了StackOverflow的这个问题,但没有得到答案。



我的问题是



<$回音日期('Ym-d',strtotime('2012-September-09')); p $ p> //输出 - 2012-09-01

echo date('Y-m-d',strtotime('09 -september-2012')); //输出 - 2012-09-09

键盘



我很困惑,为什么第一种格式不能产生正确的答案。任何帮助?

解决方案

手册



如果分隔符是斜杠(/),那么美国m /假设y而如果分隔符是破折号( - )或点(。),则假定欧洲d-m-y格式


I encountered with this question today on StackOverflow but didn't get answer.

My question is

echo date('Y-m-d',strtotime('2012-september-09')); // output - 2012-09-01

echo date('Y-m-d',strtotime('09-september-2012')); // output - 2012-09-09

Codepad

I am confused that why the first format don't produce correct answer. Any Help?

解决方案

From the manual:

if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed.

这篇关于日期功能的奇怪行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆