xref: /PHP-7.2/ext/date/tests/014.phpt (revision 17ccbeec)
1--TEST--
2timezone_offset_get() tests
3--FILE--
4<?php
5date_default_timezone_set('UTC');
6
7$dto = date_create("2006-12-12");
8var_dump($dto);
9
10$dtz = date_timezone_get($dto);
11var_dump($dtz);
12
13var_dump(timezone_offset_get());
14var_dump(timezone_offset_get($dtz, $dto));
15var_dump(timezone_offset_get($dto, $dtz));
16
17echo "Done\n";
18
19?>
20--EXPECTF--
21object(DateTime)#%d (3) {
22  ["date"]=>
23  string(26) "2006-12-12 00:00:00.000000"
24  ["timezone_type"]=>
25  int(3)
26  ["timezone"]=>
27  string(3) "UTC"
28}
29object(DateTimeZone)#%d (2) {
30  ["timezone_type"]=>
31  int(3)
32  ["timezone"]=>
33  string(3) "UTC"
34}
35
36Warning: timezone_offset_get() expects exactly 2 parameters, 0 given in %s on line %d
37bool(false)
38int(0)
39
40Fatal error: Uncaught TypeError: Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, instance of DateTime given in %s:%d
41Stack trace:
42#0 %s(%d): timezone_offset_get(Object(DateTime), Object(DateTimeZone))
43#1 {main}
44  thrown in %s on line %d
45