[英]Why is php strtotime() not working on a date?
This is the code I have used. 这是我使用的代码。 Why can't it understand this date?
为什么不能理解这个日期?
strtotime('FRI OCT 14TH 2016'); //returns Thursday 01 01 1970
Try this: 尝试这个:
echo date('d-m-Y', strtotime('FRI OCT 14 2016')); // remove TH from 14TH
it will return 它将返回
14-10-2016
2016年10月14日
As Neat mentioned in a comment : 正如Neat 在评论中提到的 :
Because thats not a supported format, Date Formats .
因为那不是受支持的格式,所以使用Date Formats 。
Looking at the PHP documentation for Date Formats , the first row in the table describes the suffixes supported on dates (see the screenshot below). 查看PHP文档中的Date Formats ,表格的第一行描述了日期支持的后缀(请参见下面的屏幕截图)。 Notice that the letters are all lower-case.
请注意,字母均为小写。
Thus as was mentioned in comments, use lower-case letters for the suffixes. 因此,正如注释中提到的那样,对后缀使用小写字母。
strtotime('FRI OCT 14th 2016');
See a demonstration of this change in this playground example . 在此操场示例中查看有关此更改的演示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.