xref: /PHP-7.2/ext/date/tests/bug27780.phpt (revision cf60f26d)
1--TEST--
2Bug #27780 (strtotime(+1 xxx) returns a wrong date/time)
3--SKIPIF--
4<?php
5if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
6	die("skip. Not the same TZ on windows.");
7}
8--FILE--
9<?php
10$timezones = array (
11	"America/Chicago", "Europe/Amsterdam", "Asia/Jerusalem",
12	"Asia/Singapore", "America/Sao_Paulo"
13);
14
15$timestrings = array (
16	"2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +59 seconds",
17	"2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +60 seconds",
18	"2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +61 seconds",
19	"2004-04-07 00:00:00 -21 days",
20	"2004-04-07 00:00:00 11 days ago",
21	"2004-04-07 00:00:00 -10 day +2 hours",
22	"2004-04-07 00:00:00 -1 day",
23	"2004-04-07 00:00:00",
24	"2004-04-07 00:00:00 +1 hour",
25	"2004-04-07 00:00:00 +2 hour",
26	"2004-04-07 00:00:00 +1 day",
27	"2004-04-07 00:00:00 1 day",
28	"2004-04-07 00:00:00 +21 days",
29);
30
31foreach ($timezones as $timezone) {
32	date_default_timezone_set($timezone);
33	echo $timezone, "\n";
34
35	foreach ($timestrings as $timestring) {
36		$time = strtotime($timestring);
37
38		echo $time, strftime(" [%Y-%m-%d %H:%M:%S %Z]", $time), " [$timestring]\n";
39	}
40
41	echo "\n";
42}
43?>
44--EXPECTF--
45America/Chicago
461076824799 [2004-02-14 23:59:59 CST] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +59 seconds]
471076824800 [2004-02-15 00:00:00 CST] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +60 seconds]
481076824801 [2004-02-15 00:00:01 CST] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +61 seconds]
491079503200 [2004-03-17 00:00:00 CST] [2004-04-07 00:00:00 -21 days]
501080367200 [2004-03-27 00:00:00 CST] [2004-04-07 00:00:00 11 days ago]
511080460800 [2004-03-28 02:00:00 CST] [2004-04-07 00:00:00 -10 day +2 hours]
521081227600 [2004-04-06 00:00:00 CDT] [2004-04-07 00:00:00 -1 day]
531081314000 [2004-04-07 00:00:00 CDT] [2004-04-07 00:00:00]
541081317600 [2004-04-07 01:00:00 CDT] [2004-04-07 00:00:00 +1 hour]
551081321200 [2004-04-07 02:00:00 CDT] [2004-04-07 00:00:00 +2 hour]
561081400400 [2004-04-08 00:00:00 CDT] [2004-04-07 00:00:00 +1 day]
571081400400 [2004-04-08 00:00:00 CDT] [2004-04-07 00:00:00 1 day]
581083128400 [2004-04-28 00:00:00 CDT] [2004-04-07 00:00:00 +21 days]
59
60Europe/Amsterdam
611076799599 [2004-02-14 23:59:59 CET] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +59 seconds]
621076799600 [2004-02-15 00:00:00 CET] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +60 seconds]
631076799601 [2004-02-15 00:00:01 CET] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +61 seconds]
641079478000 [2004-03-17 00:00:00 CET] [2004-04-07 00:00:00 -21 days]
651080342000 [2004-03-27 00:00:00 CET] [2004-04-07 00:00:00 11 days ago]
661080435600 [2004-03-28 03:00:00 CEST] [2004-04-07 00:00:00 -10 day +2 hours]
671081202400 [2004-04-06 00:00:00 CEST] [2004-04-07 00:00:00 -1 day]
681081288800 [2004-04-07 00:00:00 CEST] [2004-04-07 00:00:00]
691081292400 [2004-04-07 01:00:00 CEST] [2004-04-07 00:00:00 +1 hour]
701081296000 [2004-04-07 02:00:00 CEST] [2004-04-07 00:00:00 +2 hour]
711081375200 [2004-04-08 00:00:00 CEST] [2004-04-07 00:00:00 +1 day]
721081375200 [2004-04-08 00:00:00 CEST] [2004-04-07 00:00:00 1 day]
731083103200 [2004-04-28 00:00:00 CEST] [2004-04-07 00:00:00 +21 days]
74
75Asia/Jerusalem
761076795999 [2004-02-14 23:59:59 IST] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +59 seconds]
771076796000 [2004-02-15 00:00:00 IST] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +60 seconds]
781076796001 [2004-02-15 00:00:01 IST] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +61 seconds]
791079474400 [2004-03-17 00:00:00 IST] [2004-04-07 00:00:00 -21 days]
801080338400 [2004-03-27 00:00:00 IST] [2004-04-07 00:00:00 11 days ago]
811080432000 [2004-03-28 02:00:00 IST] [2004-04-07 00:00:00 -10 day +2 hours]
821081202400 [2004-04-06 00:00:00 IST] [2004-04-07 00:00:00 -1 day]
831081288800 [2004-04-07 00:00:00 IST] [2004-04-07 00:00:00]
841081292400 [2004-04-07 02:00:00 IDT] [2004-04-07 00:00:00 +1 hour]
851081292400 [2004-04-07 02:00:00 IDT] [2004-04-07 00:00:00 +2 hour]
861081371600 [2004-04-08 00:00:00 IDT] [2004-04-07 00:00:00 +1 day]
871081371600 [2004-04-08 00:00:00 IDT] [2004-04-07 00:00:00 1 day]
881083099600 [2004-04-28 00:00:00 IDT] [2004-04-07 00:00:00 +21 days]
89
90Asia/Singapore
911076774399 [2004-02-14 23:59:59 %s] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +59 seconds]
921076774400 [2004-02-15 00:00:00 %s] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +60 seconds]
931076774401 [2004-02-15 00:00:01 %s] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +61 seconds]
941079452800 [2004-03-17 00:00:00 %s] [2004-04-07 00:00:00 -21 days]
951080316800 [2004-03-27 00:00:00 %s] [2004-04-07 00:00:00 11 days ago]
961080410400 [2004-03-28 02:00:00 %s] [2004-04-07 00:00:00 -10 day +2 hours]
971081180800 [2004-04-06 00:00:00 %s] [2004-04-07 00:00:00 -1 day]
981081267200 [2004-04-07 00:00:00 %s] [2004-04-07 00:00:00]
991081270800 [2004-04-07 01:00:00 %s] [2004-04-07 00:00:00 +1 hour]
1001081274400 [2004-04-07 02:00:00 %s] [2004-04-07 00:00:00 +2 hour]
1011081353600 [2004-04-08 00:00:00 %s] [2004-04-07 00:00:00 +1 day]
1021081353600 [2004-04-08 00:00:00 %s] [2004-04-07 00:00:00 1 day]
1031083081600 [2004-04-28 00:00:00 %s] [2004-04-07 00:00:00 +21 days]
104
105America/Sao_Paulo
1061076810399 [2004-02-14 23:59:59 %s] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +59 seconds]
1071076814000 [2004-02-15 00:00:00 %s] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +60 seconds]
1081076814001 [2004-02-15 00:00:01 %s] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +61 seconds]
1091079492400 [2004-03-17 00:00:00 %s] [2004-04-07 00:00:00 -21 days]
1101080356400 [2004-03-27 00:00:00 %s] [2004-04-07 00:00:00 11 days ago]
1111080450000 [2004-03-28 02:00:00 %s] [2004-04-07 00:00:00 -10 day +2 hours]
1121081220400 [2004-04-06 00:00:00 %s] [2004-04-07 00:00:00 -1 day]
1131081306800 [2004-04-07 00:00:00 %s] [2004-04-07 00:00:00]
1141081310400 [2004-04-07 01:00:00 %s] [2004-04-07 00:00:00 +1 hour]
1151081314000 [2004-04-07 02:00:00 %s] [2004-04-07 00:00:00 +2 hour]
1161081393200 [2004-04-08 00:00:00 %s] [2004-04-07 00:00:00 +1 day]
1171081393200 [2004-04-08 00:00:00 %s] [2004-04-07 00:00:00 1 day]
1181083121200 [2004-04-28 00:00:00 %s] [2004-04-07 00:00:00 +21 days]
119