|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2019-09-05 15:56 UTC] dzuczek at dlc-solutions dot com
Description: ------------ date_create seems to roll back a day when given a timestamp in the year 0000 this worked as expected in PHP 7.1, does not work in PHP 7.2 or greater Test script: --------------- Not working (year 0000): https://3v4l.org/manbk Working (year 0001): https://3v4l.org/uMjtB <?php $timestamp = strtotime('0000-02-20 00:00:00 UTC'); // has issues $timestamp2 = strtotime('0001-02-20 00:00:00 UTC'); // this is okay // this has issues print $timestamp . "\n"; $date_time = date_create('@' . $timestamp); print_r($date_time); // this is fine print $timestamp2 . "\n"; $date_time2 = date_create('@' . $timestamp2); print_r($date_time2); ?> Expected result: ---------------- Using 0000-02-20 00:00:00 UTC Expected (PHP 7.1) DateTime Object ( [date] => 0000-02-20 00:00:00.000000 [timezone_type] => 1 [timezone] => +00:00 ) Actual result: -------------- Using 0000-02-20 00:00:00 UTC Actual (PHP 7.2+) DateTime Object ( [date] => 0000-02-19 00:00:00.000000 [timezone_type] => 1 [timezone] => +00:00 ) The resulting date has been rolled back a day. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 08:00:01 2025 UTC |
The date was parsed in UTC (GMT) because you provided a date-only string without any time zone indicator. If you had given a date/time string w/o an indicator instead (new Date("2011-09-24T00:00:00")), it would have been parsed in your local timezone.