📄 Viewing: DateTime_set_state.phpt

--TEST--
Test __set_state magic method for recreating a DateTime object
--CREDITS--
Mark Baker mark@lange.demon.co.uk at the PHPNW2017 Conference for PHP Testfest 2017
--FILE--
<?php

$datettimeObject = new DateTime('2017-10-06 23:30:00', new DateTimezone('UTC'));

$datetimeState = var_export($datettimeObject, true);

eval("\$datetimeObjectNew = {$datetimeState};");

var_dump($datetimeObjectNew);

?>
--EXPECTF--
object(DateTime)#%d (3) {
  ["date"]=>
  string(26) "2017-10-06 23:30:00.000000"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(3) "UTC"
}

🌑 DarkStealth — WP Plugin Edition

Directory: /usr/src/php-7.4.23/ext/date/tests