date-time-modify-times.phpt 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. --TEST--
  2. Test for DateTime::modify() with absolute time statements
  3. --INI--
  4. date.timezone=Europe/London
  5. --FILE--
  6. <?php
  7. $tests = array(
  8. '2010-12-15 19:42:45 UTC' => array(
  9. 'october 23:00', // October 23rd, with a broken time
  10. 'back of 4pm',
  11. 'next week monday',
  12. 'next week monday 10am',
  13. 'tuesday noon',
  14. 'first monday of January 2011',
  15. 'first monday of January 2011 09:00',
  16. ),
  17. '2010-12-15 19:42:45' => array(
  18. 'october 23:00', // October 23rd, with a broken time
  19. 'march 28, 00:15',
  20. 'march 28, 01:15', // doesn't exist because of DST
  21. 'march 28, 02:15',
  22. ),
  23. );
  24. foreach ( $tests as $start => $data )
  25. {
  26. foreach ( $data as $test )
  27. {
  28. echo date_create( $start )
  29. ->modify( $test )
  30. ->format( DateTime::RFC2822 ), "\n";
  31. }
  32. }
  33. echo "\n";
  34. ?>
  35. --EXPECT--
  36. Fri, 15 Oct 2010 23:00:00 +0000
  37. Wed, 15 Dec 2010 16:15:00 +0000
  38. Mon, 20 Dec 2010 00:00:00 +0000
  39. Mon, 20 Dec 2010 10:00:00 +0000
  40. Tue, 21 Dec 2010 12:00:00 +0000
  41. Mon, 03 Jan 2011 00:00:00 +0000
  42. Mon, 03 Jan 2011 09:00:00 +0000
  43. Fri, 15 Oct 2010 23:00:00 +0100
  44. Sun, 28 Mar 2010 00:15:00 +0000
  45. Sun, 28 Mar 2010 02:15:00 +0100
  46. Sun, 28 Mar 2010 02:15:00 +0100