|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-05-19 16:06 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 13:00:01 2025 UTC |
Description: ------------ I was initialising DateTime objects to test validity of date strings when I came across an odd bug. The string "East Anglia" gets parsed the same way as some time today. Strangely, strtotime does not parse the string. Reproduce code: --------------- $date = new DateTime('AAAAA'); echo $date->format('U'); will correctly throw an exception: Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct() [<a href='datetime.--construct'>datetime.--construct</a>]: Failed to parse time string (AAA) at position 0 (A): $date = new DateTime('East Anglia'); echo $date->format('U'); Gets parsed as if it were now + 7 hours. Expected result: ---------------- An exception: Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct() [<a href='datetime.--construct'>datetime.--construct</a>]: Failed to parse time string (AAA) at position 0 (A): Actual result: -------------- Gets parsed as a time string.