3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $daysInMonth = array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); $timestampFailing = false; $errorCount = 0; for ($year = 1500; $year < 2000; $year++) { for ($month = 1; $month <= 12; $month++) { for ($day = 1; $day < $daysInMonth[$month]; $day++) { if ($errorCount > 10) { echo "too many errors."; exit; } $baseString = sprintf("%4d-%02d-%02d 00:00:00", $year, $month, $day); $timestamp = strtotime($baseString); // Currently failing, ignore if (!$timestamp && $timestampFailing) { continue; } // Newly failed: log and continue if (!$timestamp) { $timestampFailing = true; $errorCount++; echo "Timestamp failing start at $baseString\n"; continue; } // Stopped failing: log and continue if ($timestampFailing && $timestamp) { $timestampFailing = false; $errorCount++; echo "Timestamp failinng end at $baseString\n"; } // Failed round trip. $roundTrip = date("Y-m-d H:i:s", $timestamp); if ($baseString !== $roundTrip) { $errorCount++; echo "$baseString ($timestamp) $roundTrip\n"; } } } }
Output for 4.3.0 - 5.0.5, 5.2.6 - 7.1.0
1916-05-01 00:00:00 (-1693700372) 1916-05-01 01:00:00 1937-07-01 00:00:00 (-1025745572) 1937-07-01 00:00:28 1940-05-16 00:00:00 (-935022000) 1940-05-16 01:40:00
Output for 5.1.2 - 5.2.5
Timestamp failing start at 1500-01-01 00:00:00 Timestamp failinng end at 1901-12-14 00:00:00 1916-05-01 00:00:00 (-1693700372) 1916-05-01 01:00:00 1937-07-01 00:00:00 (-1025745572) 1937-07-01 00:00:28 1940-05-16 00:00:00 (-935022000) 1940-05-16 01:40:00
Output for 5.1.0 - 5.1.1
Timestamp failing start at 1500-01-01 00:00:00 Timestamp failinng end at 1901-12-14 00:00:00 1904-01-01 00:00:00 (-2082845972) 1904-01-02 00:00:00 1904-01-02 00:00:00 (-2082759572) 1904-01-03 00:00:00 1904-01-03 00:00:00 (-2082673172) 1904-01-04 00:00:00 1904-01-04 00:00:00 (-2082586772) 1904-01-05 00:00:00 1904-01-05 00:00:00 (-2082500372) 1904-01-06 00:00:00 1904-01-06 00:00:00 (-2082413972) 1904-01-07 00:00:00 1904-01-07 00:00:00 (-2082327572) 1904-01-08 00:00:00 1904-01-08 00:00:00 (-2082241172) 1904-01-09 00:00:00 1904-01-09 00:00:00 (-2082154772) 1904-01-10 00:00:00 too many errors.