PHP strtotime返回false [英] PHP strtotime returning false

查看:915
本文介绍了PHP strtotime返回false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是数据库的输出,我试图从数据库中获取开始日期和日期之间的几个月。以下是我的输出

Below is the output from a database and I am trying to get the number of months between the start date and the date from the database. Below is my output

string(10) "12/12/2010" Date : 12/12/2010 - 1292112000
string(10) "19/04/2000" Date : 19/04/2000 -
string(10) "08/08/2007" Date : 08/08/2007 - 1186527600
string(10) "20/06/2011" Date : 20/06/2011 - 

看,第二个和第四个unix时间戳是空的。我不知道可能会导致这个问题。以下是我正在使用的代码来回显您以前看到的内容。

As you can see, the second and fourth unix timestamps are empty. I don't know what could be causing the issue. Below is the code I'm using to echo what you see above.

echo "Date : " . $row['startDate'] . " - " . strtotime($row['startDate']) . var_dump($row['startDate']). "<br />";


推荐答案

手册


日期在m /通过查看
各种组件之间的分隔符来消除d / y或dmy格式:如果分隔符是
斜杠(/),则假定为美式m / d / y;而如果
分隔符是破折号( - )或点(。),则假定为欧洲dmy格式

Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: 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.

为避免潜在的歧义,尽可能使用ISO 8601(YYYY-MM-DD)
日期或DateTime :: createFromFormat()。

To avoid potential ambiguity, it's best to use ISO 8601 (YYYY-MM-DD) dates or DateTime::createFromFormat() when possible.

这篇关于PHP strtotime返回false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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