Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert a 13 digit Unix Timestamp to Date and time?

Tags:

I have this 13 digit timestamp 1443852054000 that i want to convert to date and time but dont succeed. I have tried this codes:

echo date('Y-m-d h:i:s',$item->timestamp);  

doesnt work for me and also this

$unix_time = date('Ymdhis', strtotime($datetime )); 

and this :

$item = strtotime($txn_row['appoint_date']);  <?php echo date("Y-m-d H:i:s", $time); ?> 

what should i use?

like image 282
glendon philipp Baculio Avatar asked Oct 03 '15 19:10

glendon philipp Baculio


1 Answers

This timestamp is in milliseconds, not in seconds. Divide it by 1000 and use date function:

echo date('Y-m-d h:i:s', $item->timestamp / 1000); // e.g echo date('Y-m-d h:i:s',1443852054000/1000); // shows 2015-10-03 02:00:54 
like image 60
u_mulder Avatar answered Sep 20 '22 04:09

u_mulder