Почему эта разница во времени, когда я использую "IntlDateFormatter"? - PullRequest
0 голосов
/ 03 мая 2018

Почему эта разница во времени, когда я использую "IntlDateFormatter"?

<?php

// php v7.1

$pattern = 'yyyy-MM-dd HH:mm:ss';
$timezone = "Europe/Budapest";
$inputDateTimeStr = '1890-01-01 00:00:00';
$locale = 'hu_HU';

$intlDateFormatter = new \IntlDateFormatter( $locale,  \IntlDateFormatter::MEDIUM, \IntlDateFormatter::SHORT, \IntlTimeZone::createTimeZone($timezone), \IntlDateFormatter::GREGORIAN, $pattern
);

$dateTime = new \DateTime($inputDateTimeStr);
$dateTime->setTimezone(new \DateTimeZone($timezone));

$outputDateTimeStr = $intlDateFormatter->format($dateTime->getTimestamp());

print ' in: ' . $inputDateTimeStr
 . ' out: ' . $outputDateTimeStr // string(19) "1890-01-01 00:16:20"
 . ' diff: ' . ( strtotime($outputDateTimeStr) - strtotime($inputDateTimeStr) ) . ' seconds';

Вывод: в: 1890-01-01 00:00:00, выход: 1890-01-01 00: 16: 20 diff: 980 секунд

...