Bug #74652 [NEW]: strtotime() does not define behaviour of h/m/s when passed only a date
From: junk at talpa dot plus dot com
Operating system: ALL
PHP version: Irrelevant
Package: Documentation problem
Bug Type: Bug
Bug description:strtotime() does not define behaviour of h/m/s when passed only a date
Description:
------------
strtotime() can be given a string which only represents a "date", rather
than a specific second-granularity on that date, e.g.
$foo = strtotime('25 May 2017');
Since strtotime() returns a timestamp it must decide on a sensible point
on that day to use. As far as I can see, all versions (sensibly) assume
00 for any missing time elements, leading the example above to return a
timestamp that represents
"2017-05-25T00:00:00+00:00"
This follows through if some time elements are given, but not others,
e.g.
strtotime('25 May 2017 10pm') => "2017-05-25T22:00:00+00:00"
While it *seems* safe to rely on this behaviour, it would be better to
have it as documented behaviour of strtotime().
Expected result:
----------------
Documentation clearly indicates how the sub-day elements of the
timestamp are constructed in the absence of time information in the
input.
--
Edit bug report at https://bugs.php.net/bug.php?id=74652&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74652&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74652&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74652&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74652&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74652&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74652&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74652&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74652&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74652&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74652&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74652&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74652&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74652&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74652&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74652&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74652&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74652&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74652&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74652&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74652&r=mysqlcfg
Thread (3 messages)
- junk at talpa dot plus dot com