Converting facebook time to human readable time wi

2019-02-27 09:34发布

I retrieved this time value from facebook: 1438306200

How do I convert it to human readable format with PHP?

I tried: date('Y-m-d H:i:s', strtotime( 1438306200  ));

But it returns: 1970-01-01 01:00:00

I'm kinda new here. many thanks for any help! :)

标签: php time
1条回答
趁早两清
2楼-- · 2019-02-27 10:25

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'.

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 ;)

查看更多
登录 后发表回答