DateTime_extends_basic3.phpt 559 B

123456789101112131415161718192021222324
  1. --TEST--
  2. Test DateTime class inheritance : with user space format() 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 format() method ***\n";
  8. class DateTimeExt extends DateTime
  9. {
  10. public function format($format = "F j, Y, g:i:s a"): string
  11. {
  12. return parent::format($format);
  13. }
  14. }
  15. $d = new DateTimeExt("1967-05-01 22:30:41");
  16. echo $d->format() . "\n";
  17. ?>
  18. --EXPECT--
  19. *** Testing new DateTime() : with user format() method ***
  20. May 1, 1967, 10:30:41 pm