DateTime_extends_basic2.phpt 740 B

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