更新时间:2022-12-18 12:48:29
不需要 strtotime( ) 调用,它已经是一个时间戳:
There's no need for the strtotime( ) call, it's already a timestamp:
<?php
echo date( 'Y-m-d H:i:s', '1438306200' );
// output = '2015-07-31 03:30:00'.
编辑:您收到的另一个日期 (1970-1-1) 是 Unix Epoch,这是 PHP 能够返回的第一个日期.strtotime( '1438306200' ) 等于 0,因为您传递的是时间戳,而不是字符串.将 0 有效地传递给日期意味着距纪元 0 秒",这会导致返回 1970-1-1.只是让你知道;)
Edit: the other date you received (1970-1-1) is the Unix Epoch, which is the first date PHP is able to return. strtotime( '1438306200' ) equals 0 as what you passed is a time stamp, not a string. Passing 0 to date effectively means "0 seconds from epoch", which results in 1970-1-1 being returned. Just so you know ;)