xref: /PHP-7.3/ext/date/tests/date_parse_001.phpt (revision 782352c5)
1--TEST--
2Test basic date_parse()
3--FILE--
4<?php
5    date_default_timezone_set('UTC');
6    var_dump(date_parse("2006-12-12 10:00:00.5"));
7    var_dump(date_parse("2006-12-12"));
8    var_dump(date_parse("2006-12--12"));
9    var_dump(date_parse("2006-02-30"));
10    var_dump(date_parse("2006-03-04"));
11    var_dump(date_parse("2006-03"));
12    var_dump(date_parse("03-03"));
13    var_dump(date_parse("0-0"));
14    var_dump(date_parse(""));
15    var_dump(date_parse(array()));
16    echo "Done\n";
17?>
18--EXPECTF--
19array(12) {
20  ["year"]=>
21  int(2006)
22  ["month"]=>
23  int(12)
24  ["day"]=>
25  int(12)
26  ["hour"]=>
27  int(10)
28  ["minute"]=>
29  int(0)
30  ["second"]=>
31  int(0)
32  ["fraction"]=>
33  float(0.5)
34  ["warning_count"]=>
35  int(0)
36  ["warnings"]=>
37  array(0) {
38  }
39  ["error_count"]=>
40  int(0)
41  ["errors"]=>
42  array(0) {
43  }
44  ["is_localtime"]=>
45  bool(false)
46}
47array(12) {
48  ["year"]=>
49  int(2006)
50  ["month"]=>
51  int(12)
52  ["day"]=>
53  int(12)
54  ["hour"]=>
55  bool(false)
56  ["minute"]=>
57  bool(false)
58  ["second"]=>
59  bool(false)
60  ["fraction"]=>
61  bool(false)
62  ["warning_count"]=>
63  int(0)
64  ["warnings"]=>
65  array(0) {
66  }
67  ["error_count"]=>
68  int(0)
69  ["errors"]=>
70  array(0) {
71  }
72  ["is_localtime"]=>
73  bool(false)
74}
75array(15) {
76  ["year"]=>
77  int(2006)
78  ["month"]=>
79  int(12)
80  ["day"]=>
81  int(1)
82  ["hour"]=>
83  bool(false)
84  ["minute"]=>
85  bool(false)
86  ["second"]=>
87  bool(false)
88  ["fraction"]=>
89  bool(false)
90  ["warning_count"]=>
91  int(0)
92  ["warnings"]=>
93  array(0) {
94  }
95  ["error_count"]=>
96  int(1)
97  ["errors"]=>
98  array(1) {
99    [7]=>
100    string(20) "Unexpected character"
101  }
102  ["is_localtime"]=>
103  bool(true)
104  ["zone_type"]=>
105  int(1)
106  ["zone"]=>
107  int(-43200)
108  ["is_dst"]=>
109  bool(false)
110}
111array(12) {
112  ["year"]=>
113  int(2006)
114  ["month"]=>
115  int(2)
116  ["day"]=>
117  int(30)
118  ["hour"]=>
119  bool(false)
120  ["minute"]=>
121  bool(false)
122  ["second"]=>
123  bool(false)
124  ["fraction"]=>
125  bool(false)
126  ["warning_count"]=>
127  int(1)
128  ["warnings"]=>
129  array(1) {
130    [11]=>
131    string(27) "The parsed date was invalid"
132  }
133  ["error_count"]=>
134  int(0)
135  ["errors"]=>
136  array(0) {
137  }
138  ["is_localtime"]=>
139  bool(false)
140}
141array(12) {
142  ["year"]=>
143  int(2006)
144  ["month"]=>
145  int(3)
146  ["day"]=>
147  int(4)
148  ["hour"]=>
149  bool(false)
150  ["minute"]=>
151  bool(false)
152  ["second"]=>
153  bool(false)
154  ["fraction"]=>
155  bool(false)
156  ["warning_count"]=>
157  int(0)
158  ["warnings"]=>
159  array(0) {
160  }
161  ["error_count"]=>
162  int(0)
163  ["errors"]=>
164  array(0) {
165  }
166  ["is_localtime"]=>
167  bool(false)
168}
169array(12) {
170  ["year"]=>
171  int(2006)
172  ["month"]=>
173  int(3)
174  ["day"]=>
175  int(1)
176  ["hour"]=>
177  bool(false)
178  ["minute"]=>
179  bool(false)
180  ["second"]=>
181  bool(false)
182  ["fraction"]=>
183  bool(false)
184  ["warning_count"]=>
185  int(0)
186  ["warnings"]=>
187  array(0) {
188  }
189  ["error_count"]=>
190  int(0)
191  ["errors"]=>
192  array(0) {
193  }
194  ["is_localtime"]=>
195  bool(false)
196}
197array(15) {
198  ["year"]=>
199  bool(false)
200  ["month"]=>
201  bool(false)
202  ["day"]=>
203  bool(false)
204  ["hour"]=>
205  bool(false)
206  ["minute"]=>
207  bool(false)
208  ["second"]=>
209  bool(false)
210  ["fraction"]=>
211  bool(false)
212  ["warning_count"]=>
213  int(0)
214  ["warnings"]=>
215  array(0) {
216  }
217  ["error_count"]=>
218  int(2)
219  ["errors"]=>
220  array(2) {
221    [0]=>
222    string(20) "Unexpected character"
223    [1]=>
224    string(20) "Unexpected character"
225  }
226  ["is_localtime"]=>
227  bool(true)
228  ["zone_type"]=>
229  int(1)
230  ["zone"]=>
231  int(-10800)
232  ["is_dst"]=>
233  bool(false)
234}
235array(15) {
236  ["year"]=>
237  bool(false)
238  ["month"]=>
239  bool(false)
240  ["day"]=>
241  bool(false)
242  ["hour"]=>
243  bool(false)
244  ["minute"]=>
245  bool(false)
246  ["second"]=>
247  bool(false)
248  ["fraction"]=>
249  bool(false)
250  ["warning_count"]=>
251  int(0)
252  ["warnings"]=>
253  array(0) {
254  }
255  ["error_count"]=>
256  int(1)
257  ["errors"]=>
258  array(1) {
259    [0]=>
260    string(20) "Unexpected character"
261  }
262  ["is_localtime"]=>
263  bool(true)
264  ["zone_type"]=>
265  int(1)
266  ["zone"]=>
267  int(0)
268  ["is_dst"]=>
269  bool(false)
270}
271array(12) {
272  ["year"]=>
273  bool(false)
274  ["month"]=>
275  bool(false)
276  ["day"]=>
277  bool(false)
278  ["hour"]=>
279  bool(false)
280  ["minute"]=>
281  bool(false)
282  ["second"]=>
283  bool(false)
284  ["fraction"]=>
285  bool(false)
286  ["warning_count"]=>
287  int(0)
288  ["warnings"]=>
289  array(0) {
290  }
291  ["error_count"]=>
292  int(1)
293  ["errors"]=>
294  array(1) {
295    [0]=>
296    string(12) "Empty string"
297  }
298  ["is_localtime"]=>
299  bool(false)
300}
301
302Warning: date_parse() expects parameter 1 to be string, array given in %sdate_parse_001.php on line %d
303bool(false)
304Done
305