xref: /PHP-7.2/ext/date/tests/012.phpt (revision fdb2709d)
1--TEST--
2date_isodate_set() tests
3--FILE--
4<?php
5date_default_timezone_set('UTC');
6
7$dto = date_create("2006-12-12");
8var_dump(date_isodate_set($dto, 2006, 2, 15));
9var_dump($dto->format("Y/m/d H:i:s"));
10var_dump(date_isodate_set($dto, 2006));
11var_dump($dto->format("Y/m/d H:i:s"));
12var_dump(date_isodate_set($dto, 2006, 5));
13var_dump($dto->format("Y/m/d H:i:s"));
14var_dump(date_isodate_set($dto, 2006, 100, 15));
15var_dump($dto->format("Y/m/d H:i:s"));
16var_dump(date_isodate_set($dto, 2006, 100, 15, 10));
17var_dump($dto->format("Y/m/d H:i:s"));
18
19echo "Done\n";
20?>
21--EXPECTF--
22object(DateTime)#1 (3) {
23  ["date"]=>
24  string(26) "2006-01-23 00:00:00.000000"
25  ["timezone_type"]=>
26  int(3)
27  ["timezone"]=>
28  string(3) "UTC"
29}
30string(19) "2006/01/23 00:00:00"
31
32Warning: date_isodate_set() expects at least 3 parameters, 2 given in %s on line %d
33bool(false)
34string(19) "2006/01/23 00:00:00"
35object(DateTime)#1 (3) {
36  ["date"]=>
37  string(26) "2006-01-30 00:00:00.000000"
38  ["timezone_type"]=>
39  int(3)
40  ["timezone"]=>
41  string(3) "UTC"
42}
43string(19) "2006/01/30 00:00:00"
44object(DateTime)#1 (3) {
45  ["date"]=>
46  string(26) "2007-12-10 00:00:00.000000"
47  ["timezone_type"]=>
48  int(3)
49  ["timezone"]=>
50  string(3) "UTC"
51}
52string(19) "2007/12/10 00:00:00"
53
54Warning: date_isodate_set() expects at most 4 parameters, 5 given in %s on line %d
55bool(false)
56string(19) "2007/12/10 00:00:00"
57Done
58