bug27780.phpt 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. --TEST--
  2. Bug #27780 (strtotime(+1 xxx) returns a wrong date/time)
  3. --FILE--
  4. <?php
  5. $timezones = array (
  6. "America/Chicago", "Europe/Amsterdam", "Asia/Jerusalem",
  7. "Asia/Singapore", "America/Sao_Paulo"
  8. );
  9. $timestrings = array (
  10. "2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +59 seconds",
  11. "2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +60 seconds",
  12. "2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +61 seconds",
  13. "2004-04-07 00:00:00 -21 days",
  14. "2004-04-07 00:00:00 11 days ago",
  15. "2004-04-07 00:00:00 -10 day +2 hours",
  16. "2004-04-07 00:00:00 -1 day",
  17. "2004-04-07 00:00:00",
  18. "2004-04-07 00:00:00 +1 hour",
  19. "2004-04-07 00:00:00 +2 hour",
  20. "2004-04-07 00:00:00 +1 day",
  21. "2004-04-07 00:00:00 1 day",
  22. "2004-04-07 00:00:00 +21 days",
  23. );
  24. foreach ($timezones as $timezone) {
  25. date_default_timezone_set($timezone);
  26. echo $timezone, "\n";
  27. foreach ($timestrings as $timestring) {
  28. $time = strtotime($timestring);
  29. echo $time, date(" [Y-m-d H:i:s T]", $time), " [$timestring]\n";
  30. }
  31. echo "\n";
  32. }
  33. ?>
  34. --EXPECTF--
  35. America/Chicago
  36. 1076824799 [2004-02-14 23:59:59 CST] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +59 seconds]
  37. 1076824800 [2004-02-15 00:00:00 CST] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +60 seconds]
  38. 1076824801 [2004-02-15 00:00:01 CST] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +61 seconds]
  39. 1079503200 [2004-03-17 00:00:00 CST] [2004-04-07 00:00:00 -21 days]
  40. 1080367200 [2004-03-27 00:00:00 CST] [2004-04-07 00:00:00 11 days ago]
  41. 1080460800 [2004-03-28 02:00:00 CST] [2004-04-07 00:00:00 -10 day +2 hours]
  42. 1081227600 [2004-04-06 00:00:00 CDT] [2004-04-07 00:00:00 -1 day]
  43. 1081314000 [2004-04-07 00:00:00 CDT] [2004-04-07 00:00:00]
  44. 1081317600 [2004-04-07 01:00:00 CDT] [2004-04-07 00:00:00 +1 hour]
  45. 1081321200 [2004-04-07 02:00:00 CDT] [2004-04-07 00:00:00 +2 hour]
  46. 1081400400 [2004-04-08 00:00:00 CDT] [2004-04-07 00:00:00 +1 day]
  47. 1081400400 [2004-04-08 00:00:00 CDT] [2004-04-07 00:00:00 1 day]
  48. 1083128400 [2004-04-28 00:00:00 CDT] [2004-04-07 00:00:00 +21 days]
  49. Europe/Amsterdam
  50. 1076799599 [2004-02-14 23:59:59 CET] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +59 seconds]
  51. 1076799600 [2004-02-15 00:00:00 CET] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +60 seconds]
  52. 1076799601 [2004-02-15 00:00:01 CET] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +61 seconds]
  53. 1079478000 [2004-03-17 00:00:00 CET] [2004-04-07 00:00:00 -21 days]
  54. 1080342000 [2004-03-27 00:00:00 CET] [2004-04-07 00:00:00 11 days ago]
  55. 1080435600 [2004-03-28 03:00:00 CEST] [2004-04-07 00:00:00 -10 day +2 hours]
  56. 1081202400 [2004-04-06 00:00:00 CEST] [2004-04-07 00:00:00 -1 day]
  57. 1081288800 [2004-04-07 00:00:00 CEST] [2004-04-07 00:00:00]
  58. 1081292400 [2004-04-07 01:00:00 CEST] [2004-04-07 00:00:00 +1 hour]
  59. 1081296000 [2004-04-07 02:00:00 CEST] [2004-04-07 00:00:00 +2 hour]
  60. 1081375200 [2004-04-08 00:00:00 CEST] [2004-04-07 00:00:00 +1 day]
  61. 1081375200 [2004-04-08 00:00:00 CEST] [2004-04-07 00:00:00 1 day]
  62. 1083103200 [2004-04-28 00:00:00 CEST] [2004-04-07 00:00:00 +21 days]
  63. Asia/Jerusalem
  64. 1076795999 [2004-02-14 23:59:59 IST] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +59 seconds]
  65. 1076796000 [2004-02-15 00:00:00 IST] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +60 seconds]
  66. 1076796001 [2004-02-15 00:00:01 IST] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +61 seconds]
  67. 1079474400 [2004-03-17 00:00:00 IST] [2004-04-07 00:00:00 -21 days]
  68. 1080338400 [2004-03-27 00:00:00 IST] [2004-04-07 00:00:00 11 days ago]
  69. 1080432000 [2004-03-28 02:00:00 IST] [2004-04-07 00:00:00 -10 day +2 hours]
  70. 1081202400 [2004-04-06 00:00:00 IST] [2004-04-07 00:00:00 -1 day]
  71. 1081288800 [2004-04-07 00:00:00 IST] [2004-04-07 00:00:00]
  72. 1081292400 [2004-04-07 02:00:00 IDT] [2004-04-07 00:00:00 +1 hour]
  73. 1081292400 [2004-04-07 02:00:00 IDT] [2004-04-07 00:00:00 +2 hour]
  74. 1081371600 [2004-04-08 00:00:00 IDT] [2004-04-07 00:00:00 +1 day]
  75. 1081371600 [2004-04-08 00:00:00 IDT] [2004-04-07 00:00:00 1 day]
  76. 1083099600 [2004-04-28 00:00:00 IDT] [2004-04-07 00:00:00 +21 days]
  77. Asia/Singapore
  78. 1076774399 [2004-02-14 23:59:59 %s] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +59 seconds]
  79. 1076774400 [2004-02-15 00:00:00 %s] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +60 seconds]
  80. 1076774401 [2004-02-15 00:00:01 %s] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +61 seconds]
  81. 1079452800 [2004-03-17 00:00:00 %s] [2004-04-07 00:00:00 -21 days]
  82. 1080316800 [2004-03-27 00:00:00 %s] [2004-04-07 00:00:00 11 days ago]
  83. 1080410400 [2004-03-28 02:00:00 %s] [2004-04-07 00:00:00 -10 day +2 hours]
  84. 1081180800 [2004-04-06 00:00:00 %s] [2004-04-07 00:00:00 -1 day]
  85. 1081267200 [2004-04-07 00:00:00 %s] [2004-04-07 00:00:00]
  86. 1081270800 [2004-04-07 01:00:00 %s] [2004-04-07 00:00:00 +1 hour]
  87. 1081274400 [2004-04-07 02:00:00 %s] [2004-04-07 00:00:00 +2 hour]
  88. 1081353600 [2004-04-08 00:00:00 %s] [2004-04-07 00:00:00 +1 day]
  89. 1081353600 [2004-04-08 00:00:00 %s] [2004-04-07 00:00:00 1 day]
  90. 1083081600 [2004-04-28 00:00:00 %s] [2004-04-07 00:00:00 +21 days]
  91. America/Sao_Paulo
  92. 1076810399 [2004-02-14 23:59:59 %s] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +59 seconds]
  93. 1076814000 [2004-02-15 00:00:00 %s] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +60 seconds]
  94. 1076814001 [2004-02-15 00:00:01 %s] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +61 seconds]
  95. 1079492400 [2004-03-17 00:00:00 %s] [2004-04-07 00:00:00 -21 days]
  96. 1080356400 [2004-03-27 00:00:00 %s] [2004-04-07 00:00:00 11 days ago]
  97. 1080450000 [2004-03-28 02:00:00 %s] [2004-04-07 00:00:00 -10 day +2 hours]
  98. 1081220400 [2004-04-06 00:00:00 %s] [2004-04-07 00:00:00 -1 day]
  99. 1081306800 [2004-04-07 00:00:00 %s] [2004-04-07 00:00:00]
  100. 1081310400 [2004-04-07 01:00:00 %s] [2004-04-07 00:00:00 +1 hour]
  101. 1081314000 [2004-04-07 02:00:00 %s] [2004-04-07 00:00:00 +2 hour]
  102. 1081393200 [2004-04-08 00:00:00 %s] [2004-04-07 00:00:00 +1 day]
  103. 1081393200 [2004-04-08 00:00:00 %s] [2004-04-07 00:00:00 1 day]
  104. 1083121200 [2004-04-28 00:00:00 %s] [2004-04-07 00:00:00 +21 days]