1--TEST-- 2Test DateTime class inheritance : with user space __construct magic method 3--FILE-- 4<?php 5 6//Set the default time zone 7date_default_timezone_set("Europe/London"); 8 9echo "*** Testing new DateTime() : with user space __construct magic method ***\n"; 10 11class DateTimeExt extends DateTime 12{ 13 public function __construct ($date = null, DateTimeZone $dtz = null) 14 { 15 if($dtz === null) 16 { 17 $dtz = new DateTimeZone(date_default_timezone_get()); 18 } 19 parent::__construct($date, $dtz); 20 } 21} 22 23$d = new DateTimeExt("1967-05-01 22:30:41"); 24echo $d->format("F j, Y, g:i:s a") . "\n"; 25 26?> 27===DONE=== 28--EXPECTF-- 29*** Testing new DateTime() : with user space __construct magic method *** 30May 1, 1967, 10:30:41 pm 31===DONE=== 32