PHP功能strtotime()支持哪些日期格式? [英] What date formats does the PHP function strtotime() support?
问题描述
我非常喜欢PHP函数strtotime(),但是用户手册没有给出支持的日期格式的完整说明。它只提供了一些例子,如2000年9月10日,+1周2天4小时2秒和下周四。
我在哪里可以找到一个完整的描述?
我找不到任何官方,但是我看到使用GNU Date输入格式的教程 .programmers-corner.com / viewTutorial.php / 80rel =nofollow noreferrer详细描述了 GNU手册。
我注意到的一个差异是下一步与GNU手册中描述的
行为不匹配。使用strtotime(),下周四将给你与星期四相同的结果,除非今天是星期四。
如果今天是星期四, strtotime(Thursday)== strtotime(today)
如果今天不是星期四,那么
- strtotime(Thursday)== strtotime(next Thursday)
我正在使用PHP 5.2.6。
更新:
我想用户手册自从我发布以来已经更新了,否则我是盲目的。它现在包含指向日期和时间格式一章的链接,其中包括相对格式部分。
I really like the PHP function strtotime(), but the user manual doesn't give a complete description of the supported date formats. It only gives a few examples like "10 September 2000", "+1 week 2 days 4 hours 2 seconds", and "next Thursday".
Where can I find a complete description?
I can't find anything official, but I saw a tutorial that says strtotime() uses GNU Date Input Formats. Those are described in detail in the GNU manual.
One discrepancy I notice is that "next" doesn't match the behaviour described in the GNU manual. Using strtotime(), "next Thursday" will give you the same result as "Thursday", unless today is a Thursday.
If today is a Thursday, then
- strtotime("Thursday") == strtotime("today")
- strtotime("next Thursday") == strtotime("today + 7 days")
If today is not a Thursday, then
- strtotime("Thursday") == strtotime("next Thursday")
I'm using PHP 5.2.6.
Update:
I guess the user manual has been updated since I posted this, or else I was blind. It now contains a link to the Date and Time Formats chapter, that includes a section on relative formats.
这篇关于PHP功能strtotime()支持哪些日期格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!