/Date(1341788400000+0100)/ to DD/MM/YYYY HH:MM

ぐ巨炮叔叔 提交于 2019-12-13 06:06:18

问题


I have several dates being outputted into variables. They are formatted as follows:

/Date(1341788400000+0100)/

How would I go about formatting them using PHP into:

DD/MM/YYYY HH:MM

Thanks!


回答1:


I ended up using the following, as the initial format was in milliseconds:

$date = 1341788400000+0100;
$date = ( $date / 1000 );
$date = date("d/m/Y H:m", $date);



回答2:


$date = 1341788400000+0100;
echo date("Y/m/d H:m",$date);

Unless the +0100 is the actual time of the day (01:00) ?




回答3:


First, you parse it, e.g. using strtok() http://php.net/manual/en/function.strtok.php

Then parse it as a number.

$seconds = intval($a)

Then format it using

date("Y/m/d H:m", $seconds)`.


来源:https://stackoverflow.com/questions/11514294/date13417884000000100-to-dd-mm-yyyy-hhmm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!