简体   繁体   English

PHP简单日期问题

[英]PHP simple date question

Function 功能

echo date( "m/d/Y h:i a", "10/22/2009 12:32 am" );

Output 输出量

12/31/1969 07:00 pm 

Why is my output not giving me the correct date, what am I doing wrong? 为什么我的输出没有给我正确的日期,我在做什么错?

echo date( "m/d/Y h:i a", strtotime("10/22/2009 12:32 am" ));

第二个参数应该是时间戳,而不是日期字符串。

How you can read in the PHP Documentation for the date function the second parameter must be an unix timestamp. 如何在PHP文档中阅读有关date函数的内容,第二个参数必须是unix时间戳。 You can use the mktime Function to convert your date into a timestamp. 您可以使用mktime函数将日期转换为时间戳。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM