note 55444 added to function.strtotime
| From: | IronMo at osu1 dot php dot net | Date: | Wed, 03 Aug 2005 21:46:41 +0000 |
| Subject: | note 55444 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-93026@lists.php.net to get a copy of this message | ||
The php strtotime() function is a buggy mess (and demostrates one of the main arguments against a
perpetually buggy and unstable PHP). Avoid this function all costs unless you are positive your
code will only be run on a non-buggy version of php:
echo date( 'Y-m-d H:i:s', strtotime('Wed Aug 3 16:36:07 MDT 2005') );
and
echo date( 'Y-m-d H:i:s', strtotime('Wed Aug 3 16:36:07 2005') );
both return
1969-12-31 16:59:59
on at least php 4.3.2 and possibly others. PHP 4.3.11 does not have this problem as, I can only
assume, others more recently have not had as well.
Also beware of seemingly harmeless order changes like:
echo date( 'Y-m-d H:i:s', strtotime('2005 Aug 3 16:36:07') );
which returns the very incorrect, although still valid date:
2009-01-25 16:36:07
For these many reasons, I only use strtotime if I have no other choice--especially with data headed
for data base inserts.
----
Manual Page -- http://www.php.net/manual/en/function.strtotime.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55444
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55444&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55444&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55444&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55444&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55444&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55444&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55444&report=yes
Search -- http://master.php.net/manage/user-notes.php