Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
919 views
in Technique[技术] by (71.8m points)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...