|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-04-15 16:59 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2014-04-15 16:59 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 08 00:00:02 2026 UTC |
Description: ------------ I try convert string '13/04/2014' to DateTime Object, but this method "new DateTime('13/04/2014');", return Failed to parse time string (13/04/2014) at position 0 (1): Unexpected character. Try other dates and after this there is no problem, hope you can help me Test script: --------------- $date1 = new DateTime('12/04/2014'); var_dump($date1); $date2 = new DateTime('13/04/2014'); var_dump($date2); Expected result: ---------------- object(DateTime)[1] public 'date' => string '2014-12-04 00:00:00' (length=19) public 'timezone_type' => int 3 public 'timezone' => string 'UTC' (length=3) object(DateTime)[1] public 'date' => string '2014-12-04 00:00:00' (length=19) public 'timezone_type' => int 3 public 'timezone' => string 'UTC' (length=3) object(DateTime)[1] public 'date' => string '2014-13-04 00:00:00' (length=19) public 'timezone_type' => int 3 public 'timezone' => string 'UTC' (length=3) object(DateTime)[1] public 'date' => string '2014-13-04 23:59:59' (length=19) public 'timezone_type' => int 3 public 'timezone' => string 'UTC' (length=3) Actual result: -------------- object(DateTime)[1] public 'date' => string '2014-12-04 00:00:00' (length=19) public 'timezone_type' => int 3 public 'timezone' => string 'UTC' (length=3) object(DateTime)[1] public 'date' => string '2014-12-04 00:00:00' (length=19) public 'timezone_type' => int 3 public 'timezone' => string 'UTC' (length=3) Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (13/04/2014) at position 0 (1): Unexpected character' in D:\wamp\www\tools\bug-datetime.php on line 8 Exception: DateTime::__construct(): Failed to parse time string (13/04/2014) at position 0 (1): Unexpected character in D:\wamp\www\tools\bug-datetime.php on line 8 Call Stack # Time Memory Function Location 1 0.0000 146168 {main}( ) ..\bug-datetime.php:0 2 0.0156 147456 __construct ( ) ..\bug-datetime.php:8