DateTime_setTime_basic1.phpt 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --TEST--
  2. Test DateTime::setTime() function : basic functionality
  3. --FILE--
  4. <?php
  5. /* Prototype : public DateTime DateTime::setTime ( int $hour , int $minute [, int $second ] )
  6. * Description: Resets the current time of the DateTime object to a different time.
  7. * Source code: ext/date/php_date.c
  8. * Alias to functions: date_time_set
  9. */
  10. //Set the default time zone
  11. date_default_timezone_set("Europe/London");
  12. echo "*** Testing DateTime::setTime() : basic functionality ***\n";
  13. // Create a DateTime object
  14. $datetime = new DateTime("2009-01-31 15:14:10");
  15. echo "Initial date: " . $datetime ->format(DATE_RFC2822) . "\n";
  16. $datetime->setTime(17, 20);
  17. echo "After modification1 " . $datetime ->format(DATE_RFC2822) . "\n";
  18. $datetime->setTime(19, 05, 59);
  19. echo "After modification2 " . $datetime ->format(DATE_RFC2822) . "\n";
  20. $datetime->setTime(24, 10);
  21. echo "After modification3 " . $datetime ->format(DATE_RFC2822) . "\n";
  22. $datetime->setTime(47, 35, 47);
  23. echo "After modification4 " . $datetime ->format(DATE_RFC2822) . "\n";
  24. $datetime->setTime(54, 25);
  25. echo "After modification5 " . $datetime ->format(DATE_RFC2822) . "\n";
  26. ?>
  27. ===DONE===
  28. --EXPECTF--
  29. *** Testing DateTime::setTime() : basic functionality ***
  30. Initial date: Sat, 31 Jan 2009 15:14:10 +0000
  31. After modification1 Sat, 31 Jan 2009 17:20:00 +0000
  32. After modification2 Sat, 31 Jan 2009 19:05:59 +0000
  33. After modification3 Sun, 01 Feb 2009 00:10:00 +0000
  34. After modification4 Mon, 02 Feb 2009 23:35:47 +0000
  35. After modification5 Wed, 04 Feb 2009 06:25:00 +0000
  36. ===DONE===