strtotime_basic.phpt 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --TEST--
  2. strtotime() function - a test to show the difference in behaviour between 'first' and '1', "second" and "2"...
  3. --SKIPIF--
  4. <?php if (!function_exists('strtotime')) echo "SKIP"; ?>
  5. --FILE--
  6. <?php
  7. date_default_timezone_set('UTC');
  8. /*
  9. * The first of December 2008 is a Monday.
  10. * The term "Monday December 2008" will be parsed as the first Monday in December 2008.
  11. */
  12. /*
  13. * This is parsed as the "first following Monday OR the current day if it is a Monday"
  14. */
  15. var_dump(date('Y-m-d', strtotime('1 Monday December 2008')));
  16. /*
  17. * This is parsed as the "second following Monday OR the first following
  18. * Monday if the current day is a Monday"
  19. */
  20. var_dump(date('Y-m-d', strtotime('2 Monday December 2008')));
  21. /*
  22. * This is parsed as the "third following Monday OR the second following
  23. * Monday if the current day is a Monday"
  24. */
  25. var_dump(date('Y-m-d', strtotime('3 Monday December 2008')));
  26. /*
  27. * This is parsed as the "first following Monday after the first Monday in December"
  28. */
  29. var_dump(date('Y-m-d', strtotime('first Monday December 2008')));
  30. /*
  31. * This is parsed as the "second following Monday after the first Monday in December"
  32. */
  33. var_dump(date('Y-m-d', strtotime('second Monday December 2008')));
  34. /*
  35. * This is parsed as the "third following Monday after the first Monday in December"
  36. */
  37. var_dump(date('Y-m-d', strtotime('third Monday December 2008')));
  38. ?>
  39. --EXPECTF--
  40. %string|unicode%(10) "2008-12-01"
  41. %string|unicode%(10) "2008-12-08"
  42. %string|unicode%(10) "2008-12-15"
  43. %string|unicode%(10) "2008-12-08"
  44. %string|unicode%(10) "2008-12-15"
  45. %string|unicode%(10) "2008-12-22"