strftime_variation4.phpt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. --TEST--
  2. Test strftime() function : usage variation - Passing month 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 month name' => "%b",
  17. 'Full month name' => "%B",
  18. 'Month as decimal' => "%m",
  19. );
  20. // loop through each element of the array for timestamp
  21. foreach($inputs as $key =>$value) {
  22. echo "\n--$key--\n";
  23. var_dump( strftime($value) );
  24. var_dump( strftime($value, $timestamp) );
  25. };
  26. ?>
  27. ===DONE===
  28. --EXPECTF--
  29. *** Testing strftime() : usage variation ***
  30. --Abbreviated month name--
  31. string(%d) "%s"
  32. string(3) "Aug"
  33. --Full month name--
  34. string(%d) "%s"
  35. string(6) "August"
  36. --Month as decimal--
  37. string(%d) "%d"
  38. string(2) "08"
  39. ===DONE===