gmdate_variation3.phpt 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. --TEST--
  2. Test gmdate() function : usage variation - Passing numeric representation of day formats.
  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. //array of values to iterate over
  15. $inputs = array(
  16. 'Day with leading zeros' => 'd',
  17. 'Day without leading zeros' => 'j',
  18. 'ISO representation' => 'N',
  19. 'Numeric representation of day' => 'w',
  20. 'Day of the year' => 'z'
  21. );
  22. // loop through each element of the array for timestamp
  23. foreach($inputs as $key =>$value) {
  24. echo "\n--$key--\n";
  25. var_dump( gmdate($value) );
  26. var_dump( gmdate($value, $timestamp) );
  27. };
  28. ?>
  29. ===DONE===
  30. --EXPECTF--
  31. *** Testing gmdate() : usage variation ***
  32. --Day with leading zeros--
  33. string(%d) "%d"
  34. string(2) "08"
  35. --Day without leading zeros--
  36. string(%d) "%d"
  37. string(1) "8"
  38. --ISO representation--
  39. string(%d) "%d"
  40. string(1) "5"
  41. --Numeric representation of day--
  42. string(%d) "%d"
  43. string(1) "5"
  44. --Day of the year--
  45. string(%d) "%d"
  46. string(3) "220"
  47. ===DONE===