strftime_variation3.phpt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. --TEST--
  2. Test strftime() function : usage variation - Passing week related format strings to format argument.
  3. --FILE--
  4. <?php
  5. /* Prototype : string strftime(string format [, int timestamp])
  6. * Description: Format a local time/date according to locale settings
  7. * Source code: ext/date/php_date.c
  8. * Alias to functions:
  9. */
  10. echo "*** Testing strftime() : usage variation ***\n";
  11. date_default_timezone_set("Asia/Calcutta");
  12. // Initialise function arguments not being substituted (if any)
  13. $timestamp = mktime(8, 8, 8, 8, 8, 2008);
  14. //array of values to iterate over
  15. $inputs = array(
  16. 'Abbreviated weekday name' => "%a",
  17. 'Full weekday name' => "%A",
  18. 'Week number of the year' => "%U",
  19. 'Week number of the year in 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( strftime($value) );
  25. var_dump( strftime($value, $timestamp) );
  26. };
  27. ?>
  28. ===DONE===
  29. --EXPECTF--
  30. *** Testing strftime() : usage variation ***
  31. --Abbreviated weekday name--
  32. string(%d) "%s"
  33. string(3) "Fri"
  34. --Full weekday name--
  35. string(%d) "%s"
  36. string(6) "Friday"
  37. --Week number of the year--
  38. string(%d) "%d"
  39. string(2) "31"
  40. --Week number of the year in decimal number--
  41. string(%d) "%d"
  42. string(2) "31"
  43. ===DONE===