Annotation of embedaddon/php/ext/date/tests/test-parse-from-format.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: date_create_from_format() and date_parse_from_format().
3: --FILE--
4: <?php
5: date_default_timezone_set('Europe/Oslo');
6: $formats = array( DATE_ATOM, DATE_COOKIE, DATE_ISO8601, DATE_RFC822,
7: DATE_RFC850, DATE_RFC1036, DATE_RFC1123, DATE_RFC2822, DATE_RFC3339,
8: DATE_RSS, DATE_W3C );
9:
10: foreach( $formats as $format )
11: {
12: $date = new DateTime( "2008-07-08T22:14:12+02:00" );
13: $formatted = $date->format( $format ) ;
14: $date2 = date_create_from_format( $format, $formatted );
15: var_dump( $format, $formatted, $date2 );
16: echo "\n";
17: if ( $date2 === false )
18: {
19: var_dump(date_parse_from_format( $format, $formatted ) );
20: }
21: }
22: ?>
23: --EXPECT--
24: string(13) "Y-m-d\TH:i:sP"
25: string(25) "2008-07-08T22:14:12+02:00"
26: object(DateTime)#2 (3) {
27: ["date"]=>
28: string(19) "2008-07-08 22:14:12"
29: ["timezone_type"]=>
30: int(1)
31: ["timezone"]=>
32: string(6) "+02:00"
33: }
34:
1.1.1.2 ! misho 35: string(16) "l, d-M-Y H:i:s T"
! 36: string(38) "Tuesday, 08-Jul-2008 22:14:12 GMT+0200"
1.1 misho 37: object(DateTime)#1 (3) {
38: ["date"]=>
39: string(19) "2008-07-08 22:14:12"
40: ["timezone_type"]=>
41: int(1)
42: ["timezone"]=>
43: string(6) "+02:00"
44: }
45:
46: string(13) "Y-m-d\TH:i:sO"
47: string(24) "2008-07-08T22:14:12+0200"
48: object(DateTime)#3 (3) {
49: ["date"]=>
50: string(19) "2008-07-08 22:14:12"
51: ["timezone_type"]=>
52: int(1)
53: ["timezone"]=>
54: string(6) "+02:00"
55: }
56:
57: string(16) "D, d M y H:i:s O"
58: string(29) "Tue, 08 Jul 08 22:14:12 +0200"
59: object(DateTime)#2 (3) {
60: ["date"]=>
61: string(19) "2008-07-08 22:14:12"
62: ["timezone_type"]=>
63: int(1)
64: ["timezone"]=>
65: string(6) "+02:00"
66: }
67:
68: string(16) "l, d-M-y H:i:s T"
69: string(36) "Tuesday, 08-Jul-08 22:14:12 GMT+0200"
70: object(DateTime)#1 (3) {
71: ["date"]=>
72: string(19) "2008-07-08 22:14:12"
73: ["timezone_type"]=>
74: int(1)
75: ["timezone"]=>
76: string(6) "+02:00"
77: }
78:
79: string(16) "D, d M y H:i:s O"
80: string(29) "Tue, 08 Jul 08 22:14:12 +0200"
81: object(DateTime)#3 (3) {
82: ["date"]=>
83: string(19) "2008-07-08 22:14:12"
84: ["timezone_type"]=>
85: int(1)
86: ["timezone"]=>
87: string(6) "+02:00"
88: }
89:
90: string(16) "D, d M Y H:i:s O"
91: string(31) "Tue, 08 Jul 2008 22:14:12 +0200"
92: object(DateTime)#2 (3) {
93: ["date"]=>
94: string(19) "2008-07-08 22:14:12"
95: ["timezone_type"]=>
96: int(1)
97: ["timezone"]=>
98: string(6) "+02:00"
99: }
100:
101: string(16) "D, d M Y H:i:s O"
102: string(31) "Tue, 08 Jul 2008 22:14:12 +0200"
103: object(DateTime)#1 (3) {
104: ["date"]=>
105: string(19) "2008-07-08 22:14:12"
106: ["timezone_type"]=>
107: int(1)
108: ["timezone"]=>
109: string(6) "+02:00"
110: }
111:
112: string(13) "Y-m-d\TH:i:sP"
113: string(25) "2008-07-08T22:14:12+02:00"
114: object(DateTime)#3 (3) {
115: ["date"]=>
116: string(19) "2008-07-08 22:14:12"
117: ["timezone_type"]=>
118: int(1)
119: ["timezone"]=>
120: string(6) "+02:00"
121: }
122:
123: string(16) "D, d M Y H:i:s O"
124: string(31) "Tue, 08 Jul 2008 22:14:12 +0200"
125: object(DateTime)#2 (3) {
126: ["date"]=>
127: string(19) "2008-07-08 22:14:12"
128: ["timezone_type"]=>
129: int(1)
130: ["timezone"]=>
131: string(6) "+02:00"
132: }
133:
134: string(13) "Y-m-d\TH:i:sP"
135: string(25) "2008-07-08T22:14:12+02:00"
136: object(DateTime)#1 (3) {
137: ["date"]=>
138: string(19) "2008-07-08 22:14:12"
139: ["timezone_type"]=>
140: int(1)
141: ["timezone"]=>
142: string(6) "+02:00"
143: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>