开发者

Converting facebook time to human readable time with PHP

开发者 https://www.devze.com 2023-03-19 07:18 出处:网络
I retrieved this time value from facebook: 1438306200 How do I convert it to human readable format with PHP?

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', strtot开发者_开发问答ime( 1438306200  ));

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

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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号