xref: /PHP-7.2/ext/date/tests/date_create-1.phpt (revision 150d0580)
1--TEST--
2date_create() function [1]
3--SKIPIF--
4<?php if (!function_exists('date_create')) echo "SKIP"; ?>
5--FILE--
6<?php
7date_default_timezone_set('Europe/Oslo');
8$tz1 = timezone_open("GMT");
9$tz2 = timezone_open("Europe/London");
10$tz3 = timezone_open("America/Los_Angeles");
11$d = array();
12$d[] = date_create("2005-07-14 22:30:41");
13$d[] = date_create("2005-07-14 22:30:41 GMT");
14$d[] = date_create("2005-07-14 22:30:41 CET");
15$d[] = date_create("2005-07-14 22:30:41 CEST");
16$d[] = date_create("2005-07-14 22:30:41 Europe/Oslo");
17$d[] = date_create("2005-07-14 22:30:41 America/Los_Angeles");
18
19$d[] = date_create("2005-07-14 22:30:41", $tz1);
20$d[] = date_create("2005-07-14 22:30:41", $tz2);
21$d[] = date_create("2005-07-14 22:30:41", $tz3);
22
23$d[] = date_create("2005-07-14 22:30:41 GMT", $tz1);
24$d[] = date_create("2005-07-14 22:30:41 GMT", $tz2);
25$d[] = date_create("2005-07-14 22:30:41 GMT", $tz3);
26
27$d[] = date_create("2005-07-14 22:30:41 Europe/Oslo", $tz1);
28$d[] = date_create("2005-07-14 22:30:41 America/Los_Angeles", $tz2);
29
30foreach($d as $date) {
31	echo $date->format(DateTime::ISO8601), "\n";
32}
33?>
34--EXPECT--
352005-07-14T22:30:41+0200
362005-07-14T22:30:41+0000
372005-07-14T22:30:41+0100
382005-07-14T22:30:41+0200
392005-07-14T22:30:41+0200
402005-07-14T22:30:41-0700
412005-07-14T22:30:41+0000
422005-07-14T22:30:41+0100
432005-07-14T22:30:41-0700
442005-07-14T22:30:41+0000
452005-07-14T22:30:41+0000
462005-07-14T22:30:41+0000
472005-07-14T22:30:41+0200
482005-07-14T22:30:41-0700
49