我正在尝试解析日期,但我的时间戳错误
<?php
// PHP version 5.5.9
// intl version 1.1.0
// ICU version 52.1
// ICU Data version 52.1
// I'm in Europe/Moscow (GMT +3)
echo date_default_timezone_get().PHP_EOL;
$df = \IntlDateFormatter::create(
'en_EN',
IntlDateFormatter::MEDIUM,
IntlDateFormatter::NONE,
'Europe/Moscow' // GMT +3
);
$timestamp = $df->parse('Jun 19, 2015');
// 1434657600 - wrong timestamp! Where is 1 hour? Must be 1434657600 + 3600 = 1434661200
echo $timestamp.PHP_EOL;
$dt = new \DateTime();
$dt->setTimestamp($timestamp);
// Thu, 18 Jun 2015 23:00:00 +0300 - wrong, must be Thu, 19 Jun 2015 00:00:00 +0300
echo $dt->format('r').PHP_EOL;
// or using date():
// echo date('r', $tm).PHP_EOL;