php - 日期函数的奇怪行为

标签 php date strtotime

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

我的问题是

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

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

最佳答案

来自manual :

如果分隔符是斜杠 (/),则假定为美式 m/d/y;而如果分隔符是破折号 (-) 或点 (.),则采用欧洲 d-m-y 格式

关于php - 日期函数的奇怪行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12278943/

相关文章:

python - 从python中的数据框中提取某些日期

c# - 如何编辑文件夹/文件的修改日期?

php - strtotime 1 个月或更早的问题

php - 将 mysql 查询传递到 while 循环中

php - 如何根据 mySQL 中的日期拆分行并使用 PHP 显示它?

php - 上传文件然后将其复制到两个不同的目录?

c# - 在 asp.net 中使用 MaskedEditExtender 在 TextBox 中显示当前日期时间

php - 使用 JavaScript 确认对话框在后台进行 PHP 调用

php future 日期显示 1970-04-01 而不是开始日期后 3 个月

php - 添加 10 分钟到 7 :30am PHP