开发者

PHP, except date function, is there any function can decode date?

Except for date function, is there any function that can decode date? I think the real date should be in recent days, not a day in 2033.

<?php
$date = '1294605921000';
echo  date("m-d-Y H:i:s", $date)开发者_Go百科;
//11-08-2033 23:55:20
?>


No, but since that timestamp is likely in milliseconds instead of seconds, divide it by 1000:

echo date("m-d-Y H:i:s", floor($date / 1000));


The timestamp looks as though it has been generated by JavaScript, which uses milliseconds. If you divide the timestamp by 1000, you get the right date:

<?php
$date = 1294605921000/1000;
echo  date("m-d-Y H:i:s", $date);
//01-09-2011 20:45:21
?>


I am assuming that this is an excel type date serial - but i dont recognise the example you put.

From the Manual http://uk.php.net/manual/en/ref.datetime.php

<?
function xl2timestamp($xl_date)
{
$timestamp = ($xl - 25569) * 86400;
return $timestamp;
}
?>


...
gmdate — Format a GMT/UTC date/time
gmstrftime — Format a GMT/UTC time/date according to locale settings
...

Or just take a look here... Old, but good PHP Manual

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜