strftime_variation16.phpt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. --TEST--
  2. Test strftime() function : usage variation - Checking time related formats which are supported other than on Windows.
  3. --SKIPIF--
  4. <?php
  5. if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
  6. die("skip Test is not valid for Windows");
  7. }
  8. ?>
  9. --FILE--
  10. <?php
  11. /* Prototype : string strftime(string format [, int timestamp])
  12. * Description: Format a local time/date according to locale settings
  13. * Source code: ext/date/php_date.c
  14. * Alias to functions:
  15. */
  16. echo "*** Testing strftime() : usage variation ***\n";
  17. // Initialise function arguments not being substituted (if any)
  18. setlocale(LC_ALL, "en_US");
  19. date_default_timezone_set("Asia/Calcutta");
  20. $timestamp = mktime(8, 8, 8, 8, 8, 2008);
  21. //array of values to iterate over
  22. $inputs = array(
  23. 'Time in a.m/p.m notation' => "%r",
  24. 'Time in 24 hour notation' => "%R",
  25. 'Current time %H:%M:%S format' => "%T",
  26. );
  27. // loop through each element of the array for timestamp
  28. foreach($inputs as $key =>$value) {
  29. echo "\n--$key--\n";
  30. var_dump( strftime($value) );
  31. var_dump( strftime($value, $timestamp) );
  32. }
  33. ?>
  34. ===DONE===
  35. --EXPECTF--
  36. *** Testing strftime() : usage variation ***
  37. --Time in a.m/p.m notation--
  38. string(%d) "%d:%d:%d %s"
  39. string(11) "08:08:08 AM"
  40. --Time in 24 hour notation--
  41. string(%d) "%d:%d"
  42. string(5) "08:08"
  43. --Current time %H:%M:%S format--
  44. string(%d) "%d:%d:%d"
  45. string(8) "08:08:08"
  46. ===DONE===