strftime_variation22.phpt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. --TEST--
  2. Test strftime() function : usage variation - Checking Preferred date and time representation 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. if(!setlocale(LC_ALL, "POSIX")) {
  9. die("skip Locale POSIX is needed by test and is not available");
  10. }
  11. ?>
  12. --FILE--
  13. <?php
  14. /* Prototype : string strftime(string format [, int timestamp])
  15. * Description: Format a local time/date according to locale settings
  16. * Source code: ext/date/php_date.c
  17. * Alias to functions:
  18. */
  19. echo "*** Testing strftime() : usage variation ***\n";
  20. // Initialise function arguments not being substituted (if any)
  21. setlocale(LC_ALL, "POSIX");
  22. putenv("LC_ALL=POSIX");
  23. date_default_timezone_set("Asia/Calcutta");
  24. $timestamp = mktime(8, 8, 8, 8, 8, 2008);
  25. //array of values to iterate over
  26. $inputs = array(
  27. 'Preferred date and time representation' => "%c",
  28. 'Preferred date representation' => "%x",
  29. 'Preferred time representation' => "%X",
  30. );
  31. // loop through each element of the array for timestamp
  32. foreach($inputs as $key =>$value) {
  33. echo "\n--$key--\n";
  34. var_dump( $value );
  35. var_dump( strftime($value, $timestamp) );
  36. }
  37. ?>
  38. ===DONE===
  39. --EXPECT--
  40. *** Testing strftime() : usage variation ***
  41. --Preferred date and time representation--
  42. string(2) "%c"
  43. string(24) "Fri Aug 8 08:08:08 2008"
  44. --Preferred date representation--
  45. string(2) "%x"
  46. string(8) "08/08/08"
  47. --Preferred time representation--
  48. string(2) "%X"
  49. string(8) "08:08:08"
  50. ===DONE===