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