gmdate_variation9.phpt 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. --TEST--
  2. Test gmdate() function : usage variation - Passing Time format options to format argument.
  3. --FILE--
  4. <?php
  5. echo "*** Testing gmdate() : usage variation ***\n";
  6. // Initialise all required variables
  7. date_default_timezone_set('UTC');
  8. $timestamp = mktime(8, 8, 8, 8, 8, 2008);
  9. $time_formats = array(
  10. 'Lowercase Ante meridiem and post meridiem' => 'a',
  11. 'Uppercase Ante meridiem and post meridiem' => 'a',
  12. 'Swatch Internet time' => 'B',
  13. '12-hour format without leading zeros' => 'g',
  14. '24-hour format without leading zeros' => 'G',
  15. '12-hour format with leading zeros' => 'h',
  16. '24-hour format with leading zeros' => 'H',
  17. 'Minutes with leading zeros' => 'i',
  18. 'Seconds with leading zeros' => 's',
  19. 'Milliseconds' => 'u',
  20. );
  21. foreach($time_formats as $key =>$value) {
  22. echo "\n--$key--\n";
  23. var_dump( gmdate($value) );
  24. var_dump( gmdate($value, $timestamp) );
  25. }
  26. ?>
  27. --EXPECTF--
  28. *** Testing gmdate() : usage variation ***
  29. --Lowercase Ante meridiem and post meridiem--
  30. string(2) "%s"
  31. string(2) "am"
  32. --Uppercase Ante meridiem and post meridiem--
  33. string(2) "%s"
  34. string(2) "am"
  35. --Swatch Internet time--
  36. string(%d) "%d"
  37. string(3) "380"
  38. --12-hour format without leading zeros--
  39. string(%d) "%d"
  40. string(1) "8"
  41. --24-hour format without leading zeros--
  42. string(%d) "%d"
  43. string(1) "8"
  44. --12-hour format with leading zeros--
  45. string(%d) "%d"
  46. string(2) "08"
  47. --24-hour format with leading zeros--
  48. string(2) "%d"
  49. string(2) "08"
  50. --Minutes with leading zeros--
  51. string(2) "%d"
  52. string(2) "08"
  53. --Seconds with leading zeros--
  54. string(2) "%d"
  55. string(2) "08"
  56. --Milliseconds--
  57. string(%d) "%d"
  58. string(6) "000000"