xref: /php-src/ext/date/tests/bug27780.phpt (revision cdc4e49b)
1--TEST--
2Bug #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
10$timestrings = array (
11    "2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +59 seconds",
12    "2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +60 seconds",
13    "2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +61 seconds",
14    "2004-04-07 00:00:00 -21 days",
15    "2004-04-07 00:00:00 11 days ago",
16    "2004-04-07 00:00:00 -10 day +2 hours",
17    "2004-04-07 00:00:00 -1 day",
18    "2004-04-07 00:00:00",
19    "2004-04-07 00:00:00 +1 hour",
20    "2004-04-07 00:00:00 +2 hour",
21    "2004-04-07 00:00:00 +1 day",
22    "2004-04-07 00:00:00 1 day",
23    "2004-04-07 00:00:00 +21 days",
24);
25
26foreach ($timezones as $timezone) {
27    date_default_timezone_set($timezone);
28    echo $timezone, "\n";
29
30    foreach ($timestrings as $timestring) {
31        $time = strtotime($timestring);
32
33        echo $time, date(" [Y-m-d H:i:s T]", $time), " [$timestring]\n";
34    }
35
36    echo "\n";
37}
38?>
39--EXPECTF--
40America/Chicago
411076824799 [2004-02-14 23:59:59 CST] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +59 seconds]
421076824800 [2004-02-15 00:00:00 CST] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +60 seconds]
431076824801 [2004-02-15 00:00:01 CST] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +61 seconds]
441079503200 [2004-03-17 00:00:00 CST] [2004-04-07 00:00:00 -21 days]
451080367200 [2004-03-27 00:00:00 CST] [2004-04-07 00:00:00 11 days ago]
461080460800 [2004-03-28 02:00:00 CST] [2004-04-07 00:00:00 -10 day +2 hours]
471081227600 [2004-04-06 00:00:00 CDT] [2004-04-07 00:00:00 -1 day]
481081314000 [2004-04-07 00:00:00 CDT] [2004-04-07 00:00:00]
491081317600 [2004-04-07 01:00:00 CDT] [2004-04-07 00:00:00 +1 hour]
501081321200 [2004-04-07 02:00:00 CDT] [2004-04-07 00:00:00 +2 hour]
511081400400 [2004-04-08 00:00:00 CDT] [2004-04-07 00:00:00 +1 day]
521081400400 [2004-04-08 00:00:00 CDT] [2004-04-07 00:00:00 1 day]
531083128400 [2004-04-28 00:00:00 CDT] [2004-04-07 00:00:00 +21 days]
54
55Europe/Amsterdam
561076799599 [2004-02-14 23:59:59 CET] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +59 seconds]
571076799600 [2004-02-15 00:00:00 CET] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +60 seconds]
581076799601 [2004-02-15 00:00:01 CET] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +61 seconds]
591079478000 [2004-03-17 00:00:00 CET] [2004-04-07 00:00:00 -21 days]
601080342000 [2004-03-27 00:00:00 CET] [2004-04-07 00:00:00 11 days ago]
611080435600 [2004-03-28 03:00:00 CEST] [2004-04-07 00:00:00 -10 day +2 hours]
621081202400 [2004-04-06 00:00:00 CEST] [2004-04-07 00:00:00 -1 day]
631081288800 [2004-04-07 00:00:00 CEST] [2004-04-07 00:00:00]
641081292400 [2004-04-07 01:00:00 CEST] [2004-04-07 00:00:00 +1 hour]
651081296000 [2004-04-07 02:00:00 CEST] [2004-04-07 00:00:00 +2 hour]
661081375200 [2004-04-08 00:00:00 CEST] [2004-04-07 00:00:00 +1 day]
671081375200 [2004-04-08 00:00:00 CEST] [2004-04-07 00:00:00 1 day]
681083103200 [2004-04-28 00:00:00 CEST] [2004-04-07 00:00:00 +21 days]
69
70Asia/Jerusalem
711076795999 [2004-02-14 23:59:59 IST] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +59 seconds]
721076796000 [2004-02-15 00:00:00 IST] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +60 seconds]
731076796001 [2004-02-15 00:00:01 IST] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +61 seconds]
741079474400 [2004-03-17 00:00:00 IST] [2004-04-07 00:00:00 -21 days]
751080338400 [2004-03-27 00:00:00 IST] [2004-04-07 00:00:00 11 days ago]
761080432000 [2004-03-28 02:00:00 IST] [2004-04-07 00:00:00 -10 day +2 hours]
771081202400 [2004-04-06 00:00:00 IST] [2004-04-07 00:00:00 -1 day]
781081288800 [2004-04-07 00:00:00 IST] [2004-04-07 00:00:00]
791081292400 [2004-04-07 02:00:00 IDT] [2004-04-07 00:00:00 +1 hour]
801081292400 [2004-04-07 02:00:00 IDT] [2004-04-07 00:00:00 +2 hour]
811081371600 [2004-04-08 00:00:00 IDT] [2004-04-07 00:00:00 +1 day]
821081371600 [2004-04-08 00:00:00 IDT] [2004-04-07 00:00:00 1 day]
831083099600 [2004-04-28 00:00:00 IDT] [2004-04-07 00:00:00 +21 days]
84
85Asia/Singapore
861076774399 [2004-02-14 23:59:59 %s] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +59 seconds]
871076774400 [2004-02-15 00:00:00 %s] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +60 seconds]
881076774401 [2004-02-15 00:00:01 %s] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +61 seconds]
891079452800 [2004-03-17 00:00:00 %s] [2004-04-07 00:00:00 -21 days]
901080316800 [2004-03-27 00:00:00 %s] [2004-04-07 00:00:00 11 days ago]
911080410400 [2004-03-28 02:00:00 %s] [2004-04-07 00:00:00 -10 day +2 hours]
921081180800 [2004-04-06 00:00:00 %s] [2004-04-07 00:00:00 -1 day]
931081267200 [2004-04-07 00:00:00 %s] [2004-04-07 00:00:00]
941081270800 [2004-04-07 01:00:00 %s] [2004-04-07 00:00:00 +1 hour]
951081274400 [2004-04-07 02:00:00 %s] [2004-04-07 00:00:00 +2 hour]
961081353600 [2004-04-08 00:00:00 %s] [2004-04-07 00:00:00 +1 day]
971081353600 [2004-04-08 00:00:00 %s] [2004-04-07 00:00:00 1 day]
981083081600 [2004-04-28 00:00:00 %s] [2004-04-07 00:00:00 +21 days]
99
100America/Sao_Paulo
1011076810399 [2004-02-14 23:59:59 %s] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +59 seconds]
1021076814000 [2004-02-15 00:00:00 %s] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +60 seconds]
1031076814001 [2004-02-15 00:00:01 %s] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +61 seconds]
1041079492400 [2004-03-17 00:00:00 %s] [2004-04-07 00:00:00 -21 days]
1051080356400 [2004-03-27 00:00:00 %s] [2004-04-07 00:00:00 11 days ago]
1061080450000 [2004-03-28 02:00:00 %s] [2004-04-07 00:00:00 -10 day +2 hours]
1071081220400 [2004-04-06 00:00:00 %s] [2004-04-07 00:00:00 -1 day]
1081081306800 [2004-04-07 00:00:00 %s] [2004-04-07 00:00:00]
1091081310400 [2004-04-07 01:00:00 %s] [2004-04-07 00:00:00 +1 hour]
1101081314000 [2004-04-07 02:00:00 %s] [2004-04-07 00:00:00 +2 hour]
1111081393200 [2004-04-08 00:00:00 %s] [2004-04-07 00:00:00 +1 day]
1121081393200 [2004-04-08 00:00:00 %s] [2004-04-07 00:00:00 1 day]
1131083121200 [2004-04-28 00:00:00 %s] [2004-04-07 00:00:00 +21 days]
114