gmdate_variation7.phpt 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. --TEST--
  2. Test gmdate() function : usage variation - Passing Year format options to format argument.
  3. --FILE--
  4. <?php
  5. /* Prototype : string gmdate(string format [, long timestamp])
  6. * Description: Format a GMT date/time
  7. * Source code: ext/date/php_date.c
  8. * Alias to functions:
  9. */
  10. echo "*** Testing gmdate() : usage variation ***\n";
  11. // Initialise all required variables
  12. date_default_timezone_set('UTC');
  13. $timestamp = mktime(8, 8, 8, 8, 8, 2008);
  14. $timestamp_non_leap_year = mktime(8, 8, 8, 8, 8, 2007);
  15. echo "\n-- Testing gmdate() function with checking non leap year using Leap Year format --\n";
  16. var_dump( gmdate('L', $timestamp_non_leap_year) );
  17. echo "\n-- Testing gmdate() function with checking leap year using Leap Year format --\n";
  18. var_dump( gmdate('L') );
  19. var_dump( gmdate('L', $timestamp) );
  20. echo "\n-- Testing gmdate() function with ISO-8601 year number format --\n";
  21. var_dump( gmdate('o') );
  22. var_dump( gmdate('o', $timestamp) );
  23. echo "\n-- Testing gmdate() function with full numeric representation of year format --\n";
  24. var_dump( gmdate('Y') );
  25. var_dump( gmdate('Y', $timestamp) );
  26. echo "\n-- Testing gmdate() function with 2 digit representation year format --\n";
  27. var_dump( gmdate('y') );
  28. var_dump( gmdate('y', $timestamp) );
  29. ?>
  30. ===DONE===
  31. --EXPECTF--
  32. *** Testing gmdate() : usage variation ***
  33. -- Testing gmdate() function with checking non leap year using Leap Year format --
  34. string(1) "0"
  35. -- Testing gmdate() function with checking leap year using Leap Year format --
  36. string(1) "%d"
  37. string(1) "1"
  38. -- Testing gmdate() function with ISO-8601 year number format --
  39. string(4) "%d"
  40. string(4) "2008"
  41. -- Testing gmdate() function with full numeric representation of year format --
  42. string(4) "%d"
  43. string(4) "2008"
  44. -- Testing gmdate() function with 2 digit representation year format --
  45. string(2) "%d"
  46. string(2) "08"
  47. ===DONE===