在 PHP 中将 unix 时间戳转换为人类可读的日期? [英] Convert a unix timestamp to a human readable date in PHP?
本文介绍了在 PHP 中将 unix 时间戳转换为人类可读的日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个来自 PHP 的时间戳值:1188604800000
I have a timestamp value from PHP: 1188604800000
当我像这样将时间格式化为人类可读的时:
When I format the time to human readable like this:
date("m/d/Y", 1188604800000)
它打印:
05/21/39635
如果我将数字放入在线 Unix 时间戳转换器,我会得到:
If I put the number into an online Unix Timestamp converter I get:
Sat, 01 Sep 2007 00:00:00 GMT
我做错了什么?
推荐答案
PHP 使用基于秒的时间戳,因此将 1188604800
除以 1000
就可以了.>
PHP uses seconds-based timestamps, so divide 1188604800
by 1000
and you are good.
php> echo date('Y-m-d', 1188604800000/1000);
2007-09-01
这篇关于在 PHP 中将 unix 时间戳转换为人类可读的日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文