php:将毫秒转换为日期 [英] php: convert milliseconds to date
本文介绍了php:将毫秒转换为日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个等于日期的字符串,表示为自Unix纪元以来的毫秒数。
我正在尝试将其输出为dmY。 / p>
我给出的字符串是1227643821310,我被告知结果应该等于 2-12-2008 ,但是继续获得 25-11-2008的结果
我的代码如下:
$ mil = 1227643821310;
$ seconds = $ mil / 1000;
echo date(d-m-Y,$ seconds);任何关于为什么会这样做的想法?
< h2_lin>解决方案
你已经做得对,1227643821根本不是02-12-2008,确实是25-11-2008。
I Have a string that is equal to a date, represented as the number of milliseconds since the Unix epoch.
I am trying to output it into d-m-Y.
The string I was given was "1227643821310", and I am told that the result should be equal to 2-12-2008, but I keep getting a result of 25-11-2008
My code is as follows:
$mil = 1227643821310;
$seconds = $mil / 1000;
echo date("d-m-Y", $seconds);
Any ideas as to why this might be?
解决方案 You are already doing it right, 1227643821 is simply not 02-12-2008, it is indeed 25-11-2008.
这篇关于php:将毫秒转换为日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文