簡體   English   中英

為什么PHP strtotime()在日期上不起作用?

[英]Why is php strtotime() not working on a date?

這是我使用的代碼。 為什么不能理解這個日期?

strtotime('FRI OCT 14TH 2016'); //returns Thursday 01 01 1970  

嘗試這個:

echo date('d-m-Y', strtotime('FRI OCT 14 2016'));   // remove TH from 14TH 

它將返回

2016年10月14日

正如Neat 在評論中提到

因為那不是受支持的格式,所以使用Date Formats

查看PHP文檔中的Date Formats ,表格的第一行描述了日期支持的后綴(請參見下面的屏幕截圖)。 請注意,字母均為小寫。

后綴的日期格式

因此,正如注釋中提到的那樣,對后綴使用小寫字母。

strtotime('FRI OCT 14th 2016');

此操場示例中查看有關此更改的演示。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM