xref: /php-src/ext/date/tests/date_constants.phpt (revision 0dfac0e3)
1--TEST--
2Date constants
3--FILE--
4<?php
5    date_default_timezone_set("Europe/Oslo");
6    $constants = array(
7        DATE_ATOM,
8        DATE_COOKIE,
9        DATE_ISO8601,
10        DATE_ISO8601_EXPANDED,
11        DATE_RFC822,
12        DATE_RFC850,
13        DATE_RFC1036,
14        DATE_RFC1123,
15        DATE_RFC7231,
16        DATE_RFC2822,
17        DATE_RFC3339,
18        DATE_RFC3339_EXTENDED,
19        DATE_RSS,
20        DATE_W3C
21    );
22
23    foreach($constants as $const) {
24        var_dump(date($const, strtotime("1 Jul 06 14:27:30 +0200")));
25        var_dump(date($const, strtotime("2006-05-30T14:32:13+02:00")));
26    }
27
28    print "\n";
29
30    var_dump(
31        DATE_ATOM             == DateTime::ATOM,
32        DATE_COOKIE           == DateTime::COOKIE,
33        DATE_ISO8601          == DateTime::ISO8601,
34        DATE_ISO8601_EXPANDED == DateTime::ISO8601_EXPANDED,
35        DATE_RFC822           == DateTime::RFC822,
36        DATE_RFC850           == DateTime::RFC850,
37        DATE_RFC1036          == DateTime::RFC1036,
38        DATE_RFC1123          == DateTime::RFC1123,
39        DATE_RFC2822          == DateTime::RFC2822,
40        DATE_RFC7231          == DateTime::RFC7231,
41        DATE_RFC3339          == DateTime::RFC3339,
42        DATE_RFC3339_EXTENDED == DateTime::RFC3339_EXTENDED,
43        DATE_RSS              == DateTime::RSS,
44        DATE_W3C              == DateTime::W3C
45    );
46?>
47--EXPECT--
48string(25) "2006-07-01T14:27:30+02:00"
49string(25) "2006-05-30T14:32:13+02:00"
50string(35) "Saturday, 01-Jul-2006 14:27:30 CEST"
51string(34) "Tuesday, 30-May-2006 14:32:13 CEST"
52string(24) "2006-07-01T14:27:30+0200"
53string(24) "2006-05-30T14:32:13+0200"
54string(26) "+2006-07-01T14:27:30+02:00"
55string(26) "+2006-05-30T14:32:13+02:00"
56string(29) "Sat, 01 Jul 06 14:27:30 +0200"
57string(29) "Tue, 30 May 06 14:32:13 +0200"
58string(33) "Saturday, 01-Jul-06 14:27:30 CEST"
59string(32) "Tuesday, 30-May-06 14:32:13 CEST"
60string(29) "Sat, 01 Jul 06 14:27:30 +0200"
61string(29) "Tue, 30 May 06 14:32:13 +0200"
62string(31) "Sat, 01 Jul 2006 14:27:30 +0200"
63string(31) "Tue, 30 May 2006 14:32:13 +0200"
64string(29) "Sat, 01 Jul 2006 14:27:30 GMT"
65string(29) "Tue, 30 May 2006 14:32:13 GMT"
66string(31) "Sat, 01 Jul 2006 14:27:30 +0200"
67string(31) "Tue, 30 May 2006 14:32:13 +0200"
68string(25) "2006-07-01T14:27:30+02:00"
69string(25) "2006-05-30T14:32:13+02:00"
70string(29) "2006-07-01T14:27:30.000+02:00"
71string(29) "2006-05-30T14:32:13.000+02:00"
72string(31) "Sat, 01 Jul 2006 14:27:30 +0200"
73string(31) "Tue, 30 May 2006 14:32:13 +0200"
74string(25) "2006-07-01T14:27:30+02:00"
75string(25) "2006-05-30T14:32:13+02:00"
76
77bool(true)
78bool(true)
79bool(true)
80bool(true)
81bool(true)
82bool(true)
83bool(true)
84bool(true)
85bool(true)
86bool(true)
87bool(true)
88bool(true)
89bool(true)
90bool(true)
91