Learning dates and they're giving me hard time right now.
$london = new DateTime();
$london->setTimestamp(0);
$london->setTimeZone(new DateTimeZone('Europe/London'));
echo $london ->format('d-m-Y H-i-s');
result:
01-01-1970 01-00-00
Shouldn't be London in UTC +0:00
therefore midnight? For example, New York returns 19:00 of the previous date which is correctly UTC -5:00
. Moscow returns 01-01-1970 03-00-00
which is again incorrect (UTC +3:00
as opposed to UTC +4:00
)
When not using ->setTimestamp
, the London current time renders correctly, though.
Livecode: http://sandbox.onlinephpfunctions.com/
Also, my local timezone is Europe/Prague
(UTC +1:00
). Tested with date_default_timezone_set('Europe/London')
as well.
I presume there's some error in my logic?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…