本文介绍了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 />";
推荐答案
从:
为避免潜在的歧义,尽可能使用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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!