gmstrftime_variation22.phpt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. --TEST--
  2. Test gmstrftime() 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_TIME, "POSIX")) {
  9. die("skip Locale POSIX is required to run this test");
  10. }
  11. ?>
  12. --FILE--
  13. <?php
  14. /* Prototype : string gmstrftime(string format [, int timestamp])
  15. * Description: Format a GMT/UCT time/date according to locale settings
  16. * Source code: ext/date/php_date.c
  17. * Alias to functions:
  18. */
  19. echo "*** Testing gmstrftime() : usage variation ***\n";
  20. // Initialise function arguments not being substituted (if any)
  21. $timestamp = gmmktime(8, 8, 8, 8, 8, 2008);
  22. setlocale(LC_TIME, "POSIX");
  23. putenv("LC_TIME=POSIX");
  24. date_default_timezone_set("Asia/Calcutta");
  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( gmstrftime($value, $timestamp) );
  36. };
  37. ?>
  38. ===DONE===
  39. --EXPECT--
  40. *** Testing gmstrftime() : 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===