| Server IP : 198.38.94.67 / Your IP : 216.73.217.142 Web Server : LiteSpeed System : Linux d6054.dxb1.stableserver.net 5.14.0-570.25.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 9 04:57:09 EDT 2025 x86_64 User : azfilmst ( 1070) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /opt/cpanel/ea-php82/root/usr/share/tests/pecl/yaml/tests/ |
Upload File : |
--TEST--
yaml - emit -> parse roundtrip with datetime
--SKIPIF--
<?php
if(!extension_loaded('yaml')) die('skip yaml n/a');
if(!class_exists('DateTime')) die('skip DateTime n/a');
?>
--INI--
date.timezone=GMT
yaml.decode_timestamp=2
--FILE--
<?php
$original = array(
"canonical" => new DateTime("2001-12-15T02:59:43.1Z"),
"valid iso8601" => new DateTime("2001-12-14t21:59:43.10-05:00"),
"alternate iso8601" => new DateTime("2001-12-14T21:59:43.10-0500"),
"space separated" => new DateTime("2001-12-14 21:59:43.10 -5"),
"no time zone (Z)" => new DateTime("2001-12-15 2:59:43.10"),
"date (0000:00Z)" => new DateTime("2002-12-14"),
);
$yaml = yaml_emit($original);
var_dump($yaml);
$parsed = yaml_parse($yaml);
var_dump($parsed == $original);
?>
--EXPECT--
string(303) "---
canonical: 2001-12-15T02:59:43.100000+00:00
valid iso8601: 2001-12-14T21:59:43.100000-05:00
alternate iso8601: 2001-12-14T21:59:43.100000-05:00
space separated: 2001-12-14T21:59:43.100000-05:00
no time zone (Z): 2001-12-15T02:59:43.100000+00:00
date (0000:00Z): 2002-12-14T00:00:00.000000+00:00
...
"
bool(true)