Bug->Doc #61314 [Opn->Ver]: Cannot mix European and 2 digit year

From: Date: Mon, 31 Aug 2015 18:21:34 +0000
Subject: Bug->Doc #61314 [Opn->Ver]: Cannot mix European and 2 digit year
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-12686@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=61314&edit=1 ID: 61314 Updated by: cmb@php.net Reported by: mwwaygoo at hotmail dot com Summary: Cannot mix European and 2 digit year -Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem Package: Date/time related Operating System: Ubuntu 11.10 PHP Version: 5.3.10 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: > Specifying a date of 10-11-77 will epoch, […] No, strtotime() will fail for such a "date", and return FALSE as documented. > This should really say "whereas if the separator is a dot (.), > then the European d.m.y format is assumed". I agree, that some clarification in the manual is in order. Previous Comments: ------------------------------------------------------------------------ [2012-03-07 09:14:54] mwwaygoo at hotmail dot com Description: ------------ --- From manual page: http://www.php.net/function.strtotime --- Specifying a date of 10-11-77 will epoch, and not create the timestamp for 10-11-1977 as expected, according to the two notes on the strtotime() function page shown below. This should really say "whereas if the separator is a dot (.), then the European d.m.y format is assumed" Note: If the number of the year is specified in a two digit format, the values between 00-69 are mapped to 2000-2069 and 70-99 to 1970-1999. Note: ...whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed. Test script: --------------- echo date("Y-m-d H:i:s", strtotime("10-11-77 03:12:01")); // unexpected fail: supposed to be d/m/y with year 77 auto changed to 1977 echo date("Y-m-d H:i:s", strtotime("10.11.77 03:12:01")); // pass: EUR d/m/y with year 77 auto changed to 1977 echo date("Y-m-d H:i:s", strtotime("10/11/77 03:12:01")); // pass: US m/d/y echo date("Y-m-d H:i:s", strtotime("77-11-10 03:12:01")); // pass: ISO 8601 y-m-d echo date("Y-m-d H:i:s", strtotime("77/11/10 03:12:01")); // expected fail: US m/d/y data incorrect Expected result: ---------------- 1977-11-10 03:12:01 1977-11-10 03:12:01 1977-10-11 03:12:01 1977-11-10 03:12:01 1970-01-01 00:00:00 Actual result: -------------- 1970-01-01 00:00:00 1977-11-10 03:12:01 1977-10-11 03:12:01 1977-11-10 03:12:01 1970-01-01 00:00:00 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=61314&edit=1

« previous php.doc.bugs (#12686) next »