gmdate_variation9.phpt 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. --TEST--
  2. Test gmdate() function : usage variation - Passing Time 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. $time_formats = array(
  15. 'Lowercase Ante meridiem and post meridiem' => 'a',
  16. 'Uppercase Ante meridiem and post meridiem' => 'a',
  17. 'Swatch Internet time' => 'B',
  18. '12-hour format without leading zeros' => 'g',
  19. '24-hour format without leading zeros' => 'G',
  20. '12-hour format with leading zeros' => 'h',
  21. '24-hour format with leading zeros' => 'H',
  22. 'Minutes with leading zeros' => 'i',
  23. 'Seconds with leading zeros' => 's',
  24. 'Milliseconds' => 'u',
  25. );
  26. foreach($time_formats as $key =>$value) {
  27. echo "\n--$key--\n";
  28. var_dump( gmdate($value) );
  29. var_dump( gmdate($value, $timestamp) );
  30. }
  31. ?>
  32. ===DONE===
  33. --EXPECTF--
  34. *** Testing gmdate() : usage variation ***
  35. --Lowercase Ante meridiem and post meridiem--
  36. string(2) "%s"
  37. string(2) "am"
  38. --Uppercase Ante meridiem and post meridiem--
  39. string(2) "%s"
  40. string(2) "am"
  41. --Swatch Internet time--
  42. string(%d) "%d"
  43. string(3) "380"
  44. --12-hour format without leading zeros--
  45. string(%d) "%d"
  46. string(1) "8"
  47. --24-hour format without leading zeros--
  48. string(%d) "%d"
  49. string(1) "8"
  50. --12-hour format with leading zeros--
  51. string(%d) "%d"
  52. string(2) "08"
  53. --24-hour format with leading zeros--
  54. string(2) "%d"
  55. string(2) "08"
  56. --Minutes with leading zeros--
  57. string(2) "%d"
  58. string(2) "08"
  59. --Seconds with leading zeros--
  60. string(2) "%d"
  61. string(2) "08"
  62. --Milliseconds--
  63. string(%d) "%d"
  64. string(6) "000000"
  65. ===DONE===