getdate_variation4.phpt 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. --TEST--
  2. Test getdate() function : usage variation - Verifyig by supplying year-wise sample time stamps since Unix epoch time
  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. //Year wise time stamps
  16. '01 Jan 1970' => 0,
  17. '01 Jan 1971' => 31536000,
  18. '01 Jan 1972' => 63072000,
  19. '01 Jan 1973' => 94694400,
  20. );
  21. // loop through each element of the array for timestamp
  22. foreach($inputs as $key =>$value) {
  23. echo "\n--$key--\n";
  24. var_dump( getdate($value) );
  25. };
  26. ?>
  27. ===DONE===
  28. --EXPECTF--
  29. *** Testing getdate() : usage variation ***
  30. --01 Jan 1970--
  31. array(11) {
  32. ["seconds"]=>
  33. int(0)
  34. ["minutes"]=>
  35. int(30)
  36. ["hours"]=>
  37. int(5)
  38. ["mday"]=>
  39. int(1)
  40. ["wday"]=>
  41. int(4)
  42. ["mon"]=>
  43. int(1)
  44. ["year"]=>
  45. int(1970)
  46. ["yday"]=>
  47. int(0)
  48. ["weekday"]=>
  49. string(8) "Thursday"
  50. ["month"]=>
  51. string(7) "January"
  52. [0]=>
  53. int(0)
  54. }
  55. --01 Jan 1971--
  56. array(11) {
  57. ["seconds"]=>
  58. int(0)
  59. ["minutes"]=>
  60. int(30)
  61. ["hours"]=>
  62. int(5)
  63. ["mday"]=>
  64. int(1)
  65. ["wday"]=>
  66. int(5)
  67. ["mon"]=>
  68. int(1)
  69. ["year"]=>
  70. int(1971)
  71. ["yday"]=>
  72. int(0)
  73. ["weekday"]=>
  74. string(6) "Friday"
  75. ["month"]=>
  76. string(7) "January"
  77. [0]=>
  78. int(31536000)
  79. }
  80. --01 Jan 1972--
  81. array(11) {
  82. ["seconds"]=>
  83. int(0)
  84. ["minutes"]=>
  85. int(30)
  86. ["hours"]=>
  87. int(5)
  88. ["mday"]=>
  89. int(1)
  90. ["wday"]=>
  91. int(6)
  92. ["mon"]=>
  93. int(1)
  94. ["year"]=>
  95. int(1972)
  96. ["yday"]=>
  97. int(0)
  98. ["weekday"]=>
  99. string(8) "Saturday"
  100. ["month"]=>
  101. string(7) "January"
  102. [0]=>
  103. int(63072000)
  104. }
  105. --01 Jan 1973--
  106. array(11) {
  107. ["seconds"]=>
  108. int(0)
  109. ["minutes"]=>
  110. int(30)
  111. ["hours"]=>
  112. int(5)
  113. ["mday"]=>
  114. int(1)
  115. ["wday"]=>
  116. int(1)
  117. ["mon"]=>
  118. int(1)
  119. ["year"]=>
  120. int(1973)
  121. ["yday"]=>
  122. int(0)
  123. ["weekday"]=>
  124. string(6) "Monday"
  125. ["month"]=>
  126. string(7) "January"
  127. [0]=>
  128. int(94694400)
  129. }
  130. ===DONE===