File: mktime-3.phpt

package info (click to toggle)
php8.4 8.4.16-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 211,276 kB
  • sloc: ansic: 1,176,142; php: 35,419; sh: 11,964; cpp: 7,208; pascal: 4,951; javascript: 3,091; asm: 2,817; yacc: 2,411; makefile: 696; xml: 446; python: 301; awk: 148
file content (57 lines) | stat: -rw-r--r-- 1,637 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
--TEST--
mktime() [3] (32-bit)
--SKIPIF--
<?php if (PHP_INT_SIZE == 8) die("skip 32-bit only"); ?>
--INI--
error_reporting=2047
--FILE--
<?php
$tzs = array("America/Toronto", "Europe/Oslo");
$years = array(0, 69, 70, 71, 99, 100, 105, 1900, 1901, 1902, 1999, 2000, 2001);

foreach ($tzs as $tz) {
    echo $tz, "\n";
    date_default_timezone_set($tz);
    foreach ($years as $year) {
        printf("Y: %4d - ", $year);
        $ret = @mktime(1, 1, 1, 1, 1, $year);
        if ($ret == FALSE) {
            echo "out of range\n";
        } else {
            echo date("F ".DATE_ISO8601, $ret), "\n";
        }
    }
    echo "\n";
}
?>
--EXPECT--
America/Toronto
Y:    0 - January 2000-01-01T01:01:01-0500
Y:   69 - out of range
Y:   70 - January 1970-01-01T01:01:01-0500
Y:   71 - January 1971-01-01T01:01:01-0500
Y:   99 - January 1999-01-01T01:01:01-0500
Y:  100 - January 2000-01-01T01:01:01-0500
Y:  105 - out of range
Y: 1900 - out of range
Y: 1901 - out of range
Y: 1902 - January 1902-01-01T01:01:01-0500
Y: 1999 - January 1999-01-01T01:01:01-0500
Y: 2000 - January 2000-01-01T01:01:01-0500
Y: 2001 - January 2001-01-01T01:01:01-0500

Europe/Oslo
Y:    0 - January 2000-01-01T01:01:01+0100
Y:   69 - out of range
Y:   70 - January 1970-01-01T01:01:01+0100
Y:   71 - January 1971-01-01T01:01:01+0100
Y:   99 - January 1999-01-01T01:01:01+0100
Y:  100 - January 2000-01-01T01:01:01+0100
Y:  105 - out of range
Y: 1900 - out of range
Y: 1901 - out of range
Y: 1902 - January 1902-01-01T01:01:01+0100
Y: 1999 - January 1999-01-01T01:01:01+0100
Y: 2000 - January 2000-01-01T01:01:01+0100
Y: 2001 - January 2001-01-01T01:01:01+0100