Bug->Doc #67921 [Opn]: createFromFormat allows overflow for 'H' and 'G' so 25-99 rolls to next day

From: Date: Thu, 28 Aug 2014 16:28:11 +0000
Subject: Bug->Doc #67921 [Opn]: createFromFormat allows overflow for 'H' and 'G' so 25-99 rolls to next day
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-11451@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67921&edit=1 ID: 67921 Updated by: requinix@php.net Reported by: crazytonyi at gmail dot com Summary: createFromFormat allows overflow for 'H' and 'G' so 25-99 rolls to next day Status: Open -Type: Bug +Type: Documentation Problem Package: Date/time related PHP Version: 5.5.16 Block user comment: N Private report: N New Comment: This is standard behavior for date functions: when the input matches the format constraints (eg, 'H' is a two-digit number) then numbers above and below the valid range will over-/underflow. "100:00" isn't valid for "H:m" because the hour cannot be three digits. Previous Comments: ------------------------------------------------------------------------ [2014-08-28 07:32:34] crazytonyi at gmail dot com Description: ------------ When a value between 24 and 99 is in date/time string evaluated by DateTime:createFromFormat , it handles as valid and resulting object is Date + hours % 24 . So 36:00 is treated as date + 1 day 12:00 Expected Result: Evaluates to false. If this is by design, it should be very clearly documented. Since 100:00 returns false, this does not seem intentional. Test script: --------------- $time="30:29"; $date = DateTime::createFromFormat("H:m", $time); echo $date->format(DateTime::W3C); ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=67921&edit=1

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