getdate_variation2.phpt 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. --TEST--
  2. Test getdate() function : usage variation - Passing octal timestamp values
  3. --FILE--
  4. <?php
  5. /* Prototype : array getdate([int timestamp])
  6. * Description: Get date/time information
  7. * Source code: ext/date/php_date.c
  8. * Alias to functions:
  9. */
  10. echo "*** Testing getdate() : usage variation ***\n";
  11. //Set the default time zone
  12. date_default_timezone_set("Asia/Calcutta");
  13. //array of values to iterate over
  14. $inputs = array(
  15. //octal values
  16. 'octal 05' => 05,
  17. 'octal 010' => 010,
  18. 'octal -010' => -010,
  19. );
  20. // loop through each element of the array for timestamp
  21. foreach($inputs as $key =>$value) {
  22. echo "\n--$key--\n";
  23. var_dump( getdate($value) );
  24. };
  25. ?>
  26. ===DONE===
  27. --EXPECTF--
  28. *** Testing getdate() : usage variation ***
  29. --octal 05--
  30. array(11) {
  31. ["seconds"]=>
  32. int(5)
  33. ["minutes"]=>
  34. int(30)
  35. ["hours"]=>
  36. int(5)
  37. ["mday"]=>
  38. int(1)
  39. ["wday"]=>
  40. int(4)
  41. ["mon"]=>
  42. int(1)
  43. ["year"]=>
  44. int(1970)
  45. ["yday"]=>
  46. int(0)
  47. ["weekday"]=>
  48. string(8) "Thursday"
  49. ["month"]=>
  50. string(7) "January"
  51. [0]=>
  52. int(5)
  53. }
  54. --octal 010--
  55. array(11) {
  56. ["seconds"]=>
  57. int(8)
  58. ["minutes"]=>
  59. int(30)
  60. ["hours"]=>
  61. int(5)
  62. ["mday"]=>
  63. int(1)
  64. ["wday"]=>
  65. int(4)
  66. ["mon"]=>
  67. int(1)
  68. ["year"]=>
  69. int(1970)
  70. ["yday"]=>
  71. int(0)
  72. ["weekday"]=>
  73. string(8) "Thursday"
  74. ["month"]=>
  75. string(7) "January"
  76. [0]=>
  77. int(8)
  78. }
  79. --octal -010--
  80. array(11) {
  81. ["seconds"]=>
  82. int(52)
  83. ["minutes"]=>
  84. int(29)
  85. ["hours"]=>
  86. int(5)
  87. ["mday"]=>
  88. int(1)
  89. ["wday"]=>
  90. int(4)
  91. ["mon"]=>
  92. int(1)
  93. ["year"]=>
  94. int(1970)
  95. ["yday"]=>
  96. int(0)
  97. ["weekday"]=>
  98. string(8) "Thursday"
  99. ["month"]=>
  100. string(7) "January"
  101. [0]=>
  102. int(-8)
  103. }
  104. ===DONE===