IntlDateFormatter::parse doesn't work?

246 views Asked by At

I'm trying to parse date and I get wrong timestamp

<?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;
1

There are 1 answers

0
alexfv On

Solved by updating ICU from repository https://launchpad.net/~rzz/+archive/ubuntu/icu