xref: /PHP-8.0/ext/date/tests/bug30096.phpt (revision f8d79582)
1--TEST--
2Bug #30096 (gmmktime does not return the correct time)
3--INI--
4error_reporting=2047
5--FILE--
6<?php
7echo "no dst --> dst\n";
8$ts = -1;
9gm_date_check(01,00,00,03,27,2005);
10gm_date_check(02,00,00,03,27,2005);
11gm_date_check(03,00,00,03,27,2005);
12gm_date_check(04,00,00,03,27,2005);
13
14echo "\ndst --> no dst\n";
15$ts = -1;
16gm_date_check(01,00,00,10,30,2005);
17gm_date_check(02,00,00,10,30,2005);
18gm_date_check(03,00,00,10,30,2005);
19gm_date_check(04,00,00,10,30,2005);
20
21function gm_date_check($hour, $minute, $second, $month, $day, $year) {
22    global $ts, $tsold;
23
24    echo "gmmktime($hour,$minute,$second,$month,$day,$year): ";
25
26    $tsold = $ts;
27    $ts = gmmktime($hour, $minute, $second, $month, $day, $year);
28
29    echo $ts, " | gmdate('r', $ts):", gmdate('r', $ts);
30    if ($tsold > 0) {
31        echo " | Diff: " . ($ts - $tsold);
32    }
33    echo "\n";
34}
35
36?>
37--EXPECT--
38no dst --> dst
39gmmktime(1,0,0,3,27,2005): 1111885200 | gmdate('r', 1111885200):Sun, 27 Mar 2005 01:00:00 +0000
40gmmktime(2,0,0,3,27,2005): 1111888800 | gmdate('r', 1111888800):Sun, 27 Mar 2005 02:00:00 +0000 | Diff: 3600
41gmmktime(3,0,0,3,27,2005): 1111892400 | gmdate('r', 1111892400):Sun, 27 Mar 2005 03:00:00 +0000 | Diff: 3600
42gmmktime(4,0,0,3,27,2005): 1111896000 | gmdate('r', 1111896000):Sun, 27 Mar 2005 04:00:00 +0000 | Diff: 3600
43
44dst --> no dst
45gmmktime(1,0,0,10,30,2005): 1130634000 | gmdate('r', 1130634000):Sun, 30 Oct 2005 01:00:00 +0000
46gmmktime(2,0,0,10,30,2005): 1130637600 | gmdate('r', 1130637600):Sun, 30 Oct 2005 02:00:00 +0000 | Diff: 3600
47gmmktime(3,0,0,10,30,2005): 1130641200 | gmdate('r', 1130641200):Sun, 30 Oct 2005 03:00:00 +0000 | Diff: 3600
48gmmktime(4,0,0,10,30,2005): 1130644800 | gmdate('r', 1130644800):Sun, 30 Oct 2005 04:00:00 +0000 | Diff: 3600
49