note 60579 added to function.strtotime
| From: | shaver at qspeed dot com | Date: | Wed, 11 Jan 2006 16:13:02 +0000 |
| Subject: | note 60579 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-101565@lists.php.net to get a copy of this message | ||
I'm posting these here as I believe these to be design changes, not bugs.
For those upgrading from PHP 4 to PHP 5 there are a number of things that are different about
strtotime that I have NOT seen documented elsewhere, or at least not as clearly. I confirmed these
with two separate fresh installations of PHP 4.4.1 and PHP 5.1.1.
1) Given that today is Tuesday: PHP4 "next tuesday" will return today. PHP5 "next
tuesday" will actually return next tuesday as in "today +1week". Note that behavior
has NOT changed for "last" and "this". For the string "last tuesday"
both PHP4 and PHP5 would return "today -1week". For the string "this tuesday"
both PHP4 and PHP5 would return "today".
2) You cannot include a space immediately following a + or - in PHP 5. In PHP4 the string
"today + 1 week" works great. in PHP5 the string must be "today +1 week" to
correctly parse.
3) (Partially noted in changelog.) If you pass php4 a string that is a mess ("asdf1234")
it will return -1. If you in turn pass this to date() you'll get a warning like: Windows does
not support dates prior to midnight. This is pretty useful for catching errors in your scripts. In
PHP 5 strtotime will return FALSE which causes date() to return 12/31/69. Note that this is true of
strings that might appear right such as "two weeks".
4) (Partially noted in changelog.) If you pass php4 an empty string it will error out with a
"Notice: strtotime(): Called with empty time parameter". PHP5 will give no notice and
return the current date stamp. (A much preferred behavior IMO.)
5) Some uppercase and mixed-case strings no longer parse correctly. In php4 "Yesterday"
would parse correctly. In php5 "Yesterday" will return the infamous 1969 date. This is
also true of Tomorrow and Today.
6. The keyword "previous" is supported in PHP5. (Finally!)
Good luck with your upgrades. :)
-Will
----
Manual Page -- http://www.php.net/manual/en/function.strtotime.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+60579
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60579&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60579&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60579&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60579&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60579&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60579&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60579&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+60579&report=yes
Search -- http://master.php.net/manage/user-notes.php