strftime_variation5.phpt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. --TEST--
  2. Test strftime() function : usage variation - Passing date 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. // Initialise function arguments not being substituted (if any)
  12. setlocale(LC_ALL, "en_US");
  13. date_default_timezone_set("Asia/Calcutta");
  14. $timestamp = mktime(8, 8, 8, 8, 8, 2008);
  15. //array of values to iterate over
  16. $inputs = array(
  17. 'Year as decimal number without a century' => "%y",
  18. 'Year as decimal number including the century' => "%Y",
  19. 'Time zone offset' => "%Z",
  20. 'Time zone offset' => "%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( strftime($value) );
  26. var_dump( strftime($value, $timestamp) );
  27. };
  28. ?>
  29. ===DONE===
  30. --EXPECTF--
  31. *** Testing strftime() : usage variation ***
  32. --Year as decimal number without a century--
  33. string(%d) "%d"
  34. string(2) "08"
  35. --Year as decimal number including the century--
  36. string(%d) "%d"
  37. string(4) "2008"
  38. --Time zone offset--
  39. string(%d) "%s"
  40. string(%d) "%s"
  41. ===DONE===