idate_variation4.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. --TEST--
  2. Test idate() function : usage variation - Passing supported Date format characters to format argument.
  3. --FILE--
  4. <?php
  5. /* Prototype : int idate(string format [, int timestamp])
  6. * Description: Format a local time/date as integer
  7. * Source code: ext/date/php_date.c
  8. * Alias to functions:
  9. */
  10. echo "*** Testing idate() : usage variation ***\n";
  11. // Initialise function arguments not being substituted (if any)
  12. date_default_timezone_set("Asia/Calcutta");
  13. //array of values to iterate over
  14. $inputs = array(
  15. 'Day of the month' => 'd',
  16. 'Leap Year' =>'L',
  17. 'Month number' => 'm',
  18. 'Days in the month' => 't',
  19. 'Day of the week' => 'w',
  20. 'ISO-8601 week number' => 'W',
  21. 'Year (1 or 2 digits)' => 'y',
  22. 'Year 4 digits' => 'Y',
  23. 'Day of the year' => 'z',
  24. );
  25. // loop through each element of the array for timestamp
  26. foreach($inputs as $key =>$value) {
  27. echo "\n--$key--\n";
  28. var_dump( idate($value) );
  29. };
  30. ?>
  31. ===DONE===
  32. --EXPECTF--
  33. *** Testing idate() : usage variation ***
  34. --Day of the month--
  35. int(%d)
  36. --Leap Year--
  37. int(%d)
  38. --Month number--
  39. int(%d)
  40. --Days in the month--
  41. int(%d)
  42. --Day of the week--
  43. int(%d)
  44. --ISO-8601 week number--
  45. int(%d)
  46. --Year (1 or 2 digits)--
  47. int(%d)
  48. --Year 4 digits--
  49. int(%d)
  50. --Day of the year--
  51. int(%d)
  52. ===DONE===