note 51608 added to function.strtotime
| From: | gabrielu at hotmail dot com | Date: | Tue, 05 Apr 2005 16:45:48 +0000 |
| Subject: | note 51608 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-87511@lists.php.net to get a copy of this message | ||
While working on an employee schedule application I noticed an issue with using
strtotime('last...'). I ran tests on each weekday for each week within a year and noticed
inconsistencies while using:
date('m/d/Y', strtotime('last Wednesday', '2005-04-05'))
Most calculations of the 'last Wednesday' for each week calculated accordingly however I
noticed a problem with several dates, one being '04/05/2005' (April 5th 2005).
date('m/d/Y', strtotime('last Wednesday', '2005-04-05'))
The above should have returned '03/30/2005'. Instead, it returned '03/29/2005'.
I don't understand why the function is returning this value. Regardless, my solution:
date('m/d/Y', strtotime('-1 week' ,strtotime('Wednesday',
'2005-04-05')))
----
Manual Page -- http://www.php.net/manual/en/function.strtotime.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51608
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51608&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51608&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51608&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51608&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51608&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51608&report=yes
Search -- http://master.php.net/manage/user-notes.php