3

There's a script:

for($i=80; $i<=89; $i++)
{
    $date = '01.04.19'.$i;
    $intlDateFormatter = new \IntlDateFormatter('ru', 2, -1, 'Europe/Moscow', 1, 'dd.MM.yyyy');
    $intlDateFormatter->setLenient(false);
    $timestamp = $intlDateFormatter->parse($date);
    echo $date . ' = ' . var_export($timestamp, 1);
    echo '<br>' . PHP_EOL;
}

And script outputs:

01.04.1980 = 323384400
01.04.1981 = false
01.04.1982 = false
01.04.1983 = false
01.04.1984 = false
01.04.1985 = 481147200
01.04.1986 = 512683200
01.04.1987 = 544219200
01.04.1988 = 575841600
01.04.1989 = 607377600

What's wrong with dates: 01.04.1981, 01.04.1982, 01.04.1983, 01.04.1984? PHP 5.5.9-1

Jakub Matczak
  • 15,341
  • 5
  • 46
  • 64
Alex
  • 311
  • 2
  • 14

2 Answers2

4

I think it is because in those years Moscow changed to Daylight Savings Time on April 1st so the time between 00:00:00 and 00:01:00 didn't exist. In 1985 they changed a day earlier and in 1980 they didn't change at all

You can see details of time/date changes at; http://www.timeanddate.com/time/change/russia/moscow?year=1982

Mark_1
  • 623
  • 6
  • 16
2

For resolve the problem, need to use UTC.

In Symfony's 2.1.* case:

    'data_timezone' => 'UTC',
    'user_timezone' => 'UTC',

Symfony 2.3+:

    'model_timezone' => 'UTC',
    'view_timezone' => 'UTC',
lsouza
  • 2,448
  • 4
  • 26
  • 39
Alex
  • 311
  • 2
  • 14