gmstrftime_variation7.phpt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. --TEST--
  2. Test gmstrftime() function : usage variation - Passing day related format strings to format argument.
  3. --FILE--
  4. <?php
  5. /* Prototype : string gmstrftime(string format [, int timestamp])
  6. * Description: Format a GMT/UCT time/date according to locale settings
  7. * Source code: ext/date/php_date.c
  8. * Alias to functions:
  9. */
  10. echo "*** Testing gmstrftime() : usage variation ***\n";
  11. // Initialise function arguments not being substituted (if any)
  12. $timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
  13. setlocale(LC_ALL, "en_US");
  14. date_default_timezone_set("Asia/Calcutta");
  15. //array of values to iterate over
  16. $inputs = array(
  17. 'Day of the month as a decimal number' => "%d",
  18. 'Day of the year as a decimal number' => "%j",
  19. 'Day of the week as a decimal number' => "%w"
  20. );
  21. // loop through each element of the array for timestamp
  22. foreach($inputs as $key =>$value) {
  23. echo "\n--$key--\n";
  24. var_dump( gmstrftime($value) );
  25. var_dump( gmstrftime($value, $timestamp) );
  26. };
  27. ?>
  28. ===DONE===
  29. --EXPECTF--
  30. *** Testing gmstrftime() : usage variation ***
  31. --Day of the month as a decimal number--
  32. string(%d) "%d"
  33. string(2) "08"
  34. --Day of the year as a decimal number--
  35. string(%d) "%d"
  36. string(3) "221"
  37. --Day of the week as a decimal number--
  38. string(%d) "%d"
  39. string(1) "5"
  40. ===DONE===