ID: 20382 User updated by: nickj-phpbugs at nickj dot org Reported By: nickj-phpbugs at nickj dot org -Status: Closed +Status: Open Bug Type: Date/time related Operating System: * PHP Version: 5CVS, 4CVS (2004-04-13) Assigned To: derick New Comment:
Reopening, as the original test case is now working correctly (thank you!), but there are others that don't appear to be producing the expected results. The ones that don't work seem to differ between operating systems. For Linux, I've included some of these below as a series of ten small, separate, simple test cases, structured in the format you've indicated you prefer. Then below that I've included another ten cases for Windows 2000 systems, in the same format: ====================================================== <?php putenv("TZ=Europe/Andorra"); $tStamp = mktime (17, 17, 17, 1, 24764, 1970); print "tStamp=". date("l Y-m-d H:i:s T", $tStamp). "\n"; $strtotime_tstamp = strtotime("Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; putenv("TZ=Asia/Dubai"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T", $tStamp). "\n"; $strtotime_tstamp = strtotime("Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; putenv("TZ=Asia/Kabul"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T", $tStamp). "\n"; $strtotime_tstamp = strtotime("Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; putenv("TZ=America/Antigua"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T", $tStamp). "\n"; $strtotime_tstamp = strtotime("Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; putenv("TZ=America/Anguilla"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T", $tStamp). "\n"; $strtotime_tstamp = strtotime("Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; putenv("TZ=Europe/Tirane"); $tStamp = mktime (17, 17, 17, 1, 4849, 1970); print "tStamp=". date("l Y-m-d H:i:s T", $tStamp). "\n"; $strtotime_tstamp = strtotime("Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; putenv("TZ=Asia/Yerevan"); $tStamp = mktime (17, 17, 17, 1, 24764, 1970); print "tStamp=". date("l Y-m-d H:i:s T", $tStamp). "\n"; $strtotime_tstamp = strtotime("Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; putenv("TZ=America/Curacao"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T", $tStamp). "\n"; $strtotime_tstamp = strtotime("Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; putenv("TZ=Africa/Luanda"); $tStamp = mktime (17, 17, 17, 1, 1, 1970); print "tStamp=". date("l Y-m-d H:i:s T", $tStamp). "\n"; $strtotime_tstamp = strtotime("Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; putenv("TZ=Antarctica/McMurdo"); $tStamp = mktime (17, 17, 17, 1, 24743, 1970); print "tStamp=". date("l Y-m-d H:i:s T", $tStamp). "\n"; $strtotime_tstamp = strtotime("Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; ?> ====================================================== Results (on my system, a Debian GNU/Linux Woody 3.0r6 box), are as follows: ludo:~/tmp/php-5.1-dev/php5-200506170030/sapi/cli# ./php ~/test/test-output.php tStamp=Monday 2037-10-19 17:17:17 CEST result=Monday 2037-10-26 01:00:00 CET wanted=Monday 00:00:00 tStamp=Thursday 1970-01-01 17:17:17 GST result=Monday 1970-01-05 04:00:00 GST wanted=Monday 00:00:00 tStamp=Thursday 1970-01-01 17:17:17 AFT result=Monday 1970-01-05 04:30:00 AFT wanted=Monday 00:00:00 tStamp=Thursday 1970-01-01 17:17:17 AST result=Sunday 1970-01-04 20:00:00 AST wanted=Monday 00:00:00 tStamp=Thursday 1970-01-01 17:17:17 AST result=Sunday 1970-01-04 20:00:00 AST wanted=Monday 00:00:00 tStamp=Monday 1983-04-11 17:17:17 CET result=Monday 1983-04-18 01:00:00 CEST wanted=Monday 00:00:00 tStamp=Monday 2037-10-19 17:17:17 AMST result=Monday 2037-10-26 04:00:00 AMT wanted=Monday 00:00:00 tStamp=Thursday 1970-01-01 17:17:17 AST result=Sunday 1970-01-04 20:00:00 AST wanted=Monday 00:00:00 tStamp=Thursday 1970-01-01 17:17:17 WAT result=Monday 1970-01-05 01:00:00 WAT wanted=Monday 00:00:00 tStamp=Monday 2037-09-28 17:17:17 NZST result=Monday 2037-10-05 13:00:00 NZDT wanted=Monday 00:00:00 ludo:~/tmp/php-5.1-dev/php5-200506170030/sapi/cli# ====================================================== However, on a windows 2000 system, the above tests work OK, but these tests do not: ====================================================== <?php putenv("TZ=Australia/Adelaide"); $tStamp = mktime (17, 17, 17, 1, 1, 1971); print "tStamp=". date("l Y-m-d H:i:s T", $tStamp). "\n"; $strtotime_tstamp = strtotime("Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; putenv("TZ=Australia/Darwin"); $tStamp = mktime (17, 17, 17, 1, 88, 1971); print "tStamp=". date("l Y-m-d H:i:s T", $tStamp). "\n"; $strtotime_tstamp = strtotime("Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; putenv("TZ=Australia/Perth"); $tStamp = mktime (17, 17, 17, 1, 1, 1971); print "tStamp=". date("l Y-m-d H:i:s T", $tStamp). "\n"; $strtotime_tstamp = strtotime("Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; putenv("TZ=America/Aruba"); $tStamp = mktime (17, 17, 17, 1, 88, 1971); print "tStamp=". date("l Y-m-d H:i:s T", $tStamp). "\n"; $strtotime_tstamp = strtotime("Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; putenv("TZ=Asia/Baku"); $tStamp = mktime (17, 17, 17, 1, 1, 1971); print "tStamp=". date("l Y-m-d H:i:s T", $tStamp). "\n"; $strtotime_tstamp = strtotime("Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; putenv("TZ=Europe/Sarajevo"); $tStamp = mktime (17, 17, 17, 1, 1, 1971); print "tStamp=". date("l Y-m-d H:i:s T", $tStamp). "\n"; $strtotime_tstamp = strtotime("Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; putenv("TZ=America/Barbados"); $tStamp = mktime (17, 17, 17, 1, 1, 1971); print "tStamp=". date("l Y-m-d H:i:s T", $tStamp). "\n"; $strtotime_tstamp = strtotime("Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; putenv("TZ=Asia/Dacca"); $tStamp = mktime (17, 17, 17, 1, 1, 1971); print "tStamp=". date("l Y-m-d H:i:s T", $tStamp). "\n"; $strtotime_tstamp = strtotime("Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; putenv("TZ=Europe/Brussels"); $tStamp = mktime (17, 17, 17, 1, 1, 1971); print "tStamp=". date("l Y-m-d H:i:s T", $tStamp). "\n"; $strtotime_tstamp = strtotime("Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; putenv("TZ=Africa/Ouagadougou"); $tStamp = mktime (17, 17, 17, 1, 88, 1971); print "tStamp=". date("l Y-m-d H:i:s T", $tStamp). "\n"; $strtotime_tstamp = strtotime("Monday", $tStamp); print "result=".date("l Y-m-d H:i:s T", $strtotime_tstamp)."\n"; print "wanted=Monday 00:00:00\n\n"; ?> ====================================================== Results on a Windows 2000 SP4 box, are as follows: G:\PHP bugs\PHP bug 20382\php5.1-dev\php5-win32-200506171830>php-cgi.exe ..\..\new-test-output.php Content-type: text/html X-Powered-By: PHP/5.1.0-dev tStamp=Friday 1971-01-01 17:17:17 Aus result=Sunday 1971-01-03 14:30:00 Aus wanted=Monday 00:00:00 tStamp=Monday 1971-03-29 17:17:17 Aus result=Monday 1971-04-05 01:00:00 tra wanted=Monday 00:00:00 tStamp=Friday 1971-01-01 17:17:17 Aus result=Sunday 1971-01-03 16:00:00 Aus wanted=Monday 00:00:00 tStamp=Monday 1971-03-29 17:17:17 Ame result=Monday 1971-04-05 01:00:00 ric wanted=Monday 00:00:00 tStamp=Friday 1971-01-01 17:17:17 Asi result=Sunday 1971-01-03 20:00:00 Asi wanted=Monday 00:00:00 tStamp=Friday 1971-01-01 17:17:17 Eur result=Sunday 1971-01-03 23:00:00 Eur wanted=Monday 00:00:00 tStamp=Friday 1971-01-01 17:17:17 Ame result=Monday 1971-01-04 04:00:00 Ame wanted=Monday 00:00:00 tStamp=Friday 1971-01-01 17:17:17 Asi result=Sunday 1971-01-03 18:00:00 Asi wanted=Monday 00:00:00 tStamp=Friday 1971-01-01 17:17:17 Eur result=Sunday 1971-01-03 23:00:00 Eur wanted=Monday 00:00:00 tStamp=Monday 1971-03-29 17:17:17 Afr result=Monday 1971-04-05 01:00:00 ica wanted=Monday 00:00:00 G:\PHP bugs\PHP bug 20382\php5.1-dev\php5-win32-200506171830> ==================================================================== And running the win2000 tests on the Linux box give this: ludo:~/tmp/php-5.1-dev/php5-200506170030/sapi/cli# ./php ~/test/new-test-win2000.php tStamp=Friday 1971-01-01 17:17:17 CST result=Monday 1971-01-04 00:00:00 CST wanted=Monday 00:00:00 tStamp=Monday 1971-03-29 17:17:17 CST result=Monday 1971-04-05 09:30:00 CST wanted=Monday 00:00:00 tStamp=Friday 1971-01-01 17:17:17 WST result=Monday 1971-01-04 00:00:00 WST wanted=Monday 00:00:00 tStamp=Monday 1971-03-29 17:17:17 AST result=Sunday 1971-04-04 20:00:00 AST wanted=Monday 00:00:00 tStamp=Friday 1971-01-01 17:17:17 BAKT result=Monday 1971-01-04 00:00:00 BAKT wanted=Monday 00:00:00 tStamp=Friday 1971-01-01 17:17:17 CET result=Monday 1971-01-04 00:00:00 CET wanted=Monday 00:00:00 tStamp=Friday 1971-01-01 17:17:17 AST result=Monday 1971-01-04 00:00:00 AST wanted=Monday 00:00:00 tStamp=Friday 1971-01-01 17:17:17 DACT result=Monday 1971-01-04 00:00:00 DACT wanted=Monday 00:00:00 tStamp=Friday 1971-01-01 17:17:17 CET result=Monday 1971-01-04 00:00:00 CET wanted=Monday 00:00:00 tStamp=Monday 1971-03-29 17:17:17 GMT result=Monday 1971-04-05 00:00:00 GMT wanted=Monday 00:00:00 I.e. the 2nd and 4th results are also wrong on Linux, the remaining 8 look correct (so there is some overlap in incorrect results between operating systems, although most of the time there is not). Previous Comments: ------------------------------------------------------------------------ [2005-06-16 21:35:59] [EMAIL PROTECTED] This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Fixed for PHP 5.1 ------------------------------------------------------------------------ [2004-12-12 06:49:44] sid0007 at gmailll dot com I verified this in php version 4.3.3 http://www.bonkee.com/Strtotime.php ------------------------------------------------------------------------ [2004-10-20 20:14:16] joe at dataport dot tv Oh, also forgot to mention that while "next monday" does not work, "next tuesday" does. There's definately a bug here, if "this monday" works and "next tuesday" works, it seems to me that "next monday" should work as well and that it's not just some time zone issue. ------------------------------------------------------------------------ [2004-10-19 21:30:21] joe at dataport dot tv How's this? <?php $day=date("w",strtotime("this monday")); echo $day; ?> Outputs: 1 <?php $day=date("w",strtotime("next monday")); echo $day; ?> Outputs: 0 I was going to submit a seperate bug but this definately looks related even though this is a totally different way of going about getting the same type of problem. (I knew Mondays were a little odd, but does strtotime seem to think the sunday of the next week has an extra second after midnight? As this example demonstrates it doesn't do it if you prefix the weekday with "this", just "next" or no prefix at all.) ------------------------------------------------------------------------ [2004-04-08 10:13:10] [EMAIL PROTECTED] This one shows it better: <?php putenv("TZ=Europe/Amsterdam"); $tStamp = mktime (17, 17, 17, 10, 27, 2004); echo "tStamp=". date("l Y-m-d H:i:s T", $tStamp). "\n"; $strtotime_timestamp = strtotime ("Monday", $tStamp); echo "result=". date("l Y-m-d H:i:s T", $strtotime_timestamp). "\n"; echo "wanted=Monday 2004-11-01 00:00:00 CET\n"; ?> ------------------------------------------------------------------------ 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/20382 -- Edit this bug report at http://bugs.php.net/?id=20382&edit=1