我无法将unix时间戳tp转换为正确的时间。日期还可以,但我的时间是13个小时。我使用php 5.6与cakephp3。我的网页显示了混淆事项的当前正确时间
i get 'am' and not 'pm' with 1hr slow
date_default_timezone_set('Australia/Melbourne');
$melbourne = time(); echo gmdate('d-m-Y H:i a', $melbourne);
//Error: Call to a member function setTimestamp() on null
$date->setTimestamp(1516769611.7392); //should be 2018-01-24 15:53:31
echo $date->format('U = Y-m-d H:i:s') ;
//i did include this in controller for cakephp3 use Cake\I18n\Time;
$timestamp=$item['submit_time']; //1516769611.7392
echo gmdate('d-m-Y H:i:s', $timestamp); //24-01-2018 04:53:31 time is wrong
$time = Time::createFromTimestamp( $timestamp);
echo $time;
答案 0 :(得分:0)
您可以尝试在代码顶部设置时区
date_default_timezone_set(your_time_zone);