php - IntlDateFormatter::parse doesn't work?

737

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;
975

Answer

Solution:

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

People are also looking for solutions to the problem: php - Connection reset by peer while reading response header from upstream every day at same time

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.