#23211 [Bgs]: April First Week strtotime day off error

From: Date: Tue, 22 Apr 2003 20:54:55 +0000
Subject: #23211 [Bgs]: April First Week strtotime day off error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-38087@lists.php.net to get a copy of this message
ID: 23211 Updated by: rasmus@php.net Reported By: jmalan at ocurrance dot com Status: Bogus Bug Type: Calendar related Operating System: Linux 7 PHP Version: 4.3.1 New Comment: The bug database is not a support forum. It is for reporting bugs. There is nothing wrong with the strtotime() function. It is giving you exactly what you are asking it for. In this case last saturday in MST may not be the same day as last saturday in MDT since you switched from one to the other in between that. A simple way around it is to just add a timezone fuzz factor if you don't know which timezone you are working with. As in: strtotime("12:00:00 last saturday MST") and strtotime("12:00:00 last saturday MDT"); One will give you 11am, the other 12, but both will be Saturday. If you still have trouble understanding timezones, please ask any further questions on the php-general mailing list. Previous Comments: ------------------------------------------------------------------------ [2003-04-22 13:17:11] jmalan at ocurrance dot com Unfortunately that still does not answer my question. I know how to get around the problem but the problem still exists. date("m/d/Y H:i:s",strtotime("last saturday MST")) returns 04/04/2003 23:00:00 if the time is after 2 AM sunday morning the 6th of april. Try it, set your calendar to the 7th of april 2003. ------------------------------------------------------------------------ [2003-04-22 13:04:48] jmalan at ocurrance dot com SWEEEEET!!!!!!!!! There we go, that was what I was missing. You rock man! ------------------------------------------------------------------------ [2003-04-22 12:04:22] rasmus@php.net How is the syntax completely different? Those php examples are all covered by the GNU docs as well. The whole point of the function is that it understands many different formats. And if you specify the right timezone in works just fine, just as I said. Try this: $ts1 = mktime(12,0,0,4,5,2003); echo date("l H:i:s m/d/y",$ts1); echo "<br>\n"; $ts2 = strtotime("last saturday PST",$ts1); echo "<br>\n"; echo date("l H:i:s m/d/y",$ts2); $ts3 = strtotime("last saturday PDT",$ts1); echo "<br>\n"; echo date("l H:i:s m/d/y",$ts3); This outputs: Saturday 12:00:00 04/05/03 Saturday 00:00:00 03/29/03 Friday 23:00:00 03/28/03 exactly as expected. I see no bug here. ------------------------------------------------------------------------ [2003-04-22 11:52:55] jmalan at ocurrance dot com I tried using a timezone and that did not make any difference. ------------------------------------------------------------------------ [2003-04-22 11:50:17] jmalan at ocurrance dot com I looked at the GNU link on the strtotime page and it states: 1 year 1 year ago 3 years 2 days In the examples for php it states: 1 day 1 week next Thursday last Monday The syntax is completely different in PHP than GNU: Date Input Formats. Which brings me back to my original statement, there is a bug in PHP that interprets "last saturday" (saturday as an example, any day breaks) incorrectly when daylight savings time is in effect. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/23211 -- Edit this bug report at http://bugs.php.net/?id=23211&edit=1

« previous php.bugs (#38087) next »