strtotime_basic.phpt 1.4 KB

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