localtime_variation5.phpt 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. --TEST--
  2. Test localtime() function : usage variation - Passing hexa decimal values to timestamp.
  3. --FILE--
  4. <?php
  5. /* Prototype : array localtime([int timestamp [, bool associative_array]])
  6. * Description: Returns the results of the C system call localtime as an associative array
  7. * if the associative_array argument is set to 1 other wise it is a regular array
  8. * Source code: ext/date/php_date.c
  9. * Alias to functions:
  10. */
  11. echo "*** Testing localtime() : usage variation ***\n";
  12. date_default_timezone_set("UTC");
  13. // Initialise function arguments not being substituted (if any)
  14. $is_associative = true;
  15. //array of values to iterate over
  16. $inputs = array(
  17. 'Hexa-decimal 0' => 0x0,
  18. 'Hexa-decimal 10' => 0xA,
  19. 'Hexa-decimal -10' => -0XA
  20. );
  21. foreach($inputs as $key =>$value) {
  22. echo "\n--$key--\n";
  23. var_dump( localtime($value) );
  24. var_dump( localtime($value, $is_associative) );
  25. }
  26. ?>
  27. ===DONE===
  28. --EXPECTF--
  29. *** Testing localtime() : usage variation ***
  30. --Hexa-decimal 0--
  31. array(9) {
  32. [0]=>
  33. int(0)
  34. [1]=>
  35. int(0)
  36. [2]=>
  37. int(0)
  38. [3]=>
  39. int(1)
  40. [4]=>
  41. int(0)
  42. [5]=>
  43. int(70)
  44. [6]=>
  45. int(4)
  46. [7]=>
  47. int(0)
  48. [8]=>
  49. int(0)
  50. }
  51. array(9) {
  52. ["tm_sec"]=>
  53. int(0)
  54. ["tm_min"]=>
  55. int(0)
  56. ["tm_hour"]=>
  57. int(0)
  58. ["tm_mday"]=>
  59. int(1)
  60. ["tm_mon"]=>
  61. int(0)
  62. ["tm_year"]=>
  63. int(70)
  64. ["tm_wday"]=>
  65. int(4)
  66. ["tm_yday"]=>
  67. int(0)
  68. ["tm_isdst"]=>
  69. int(0)
  70. }
  71. --Hexa-decimal 10--
  72. array(9) {
  73. [0]=>
  74. int(10)
  75. [1]=>
  76. int(0)
  77. [2]=>
  78. int(0)
  79. [3]=>
  80. int(1)
  81. [4]=>
  82. int(0)
  83. [5]=>
  84. int(70)
  85. [6]=>
  86. int(4)
  87. [7]=>
  88. int(0)
  89. [8]=>
  90. int(0)
  91. }
  92. array(9) {
  93. ["tm_sec"]=>
  94. int(10)
  95. ["tm_min"]=>
  96. int(0)
  97. ["tm_hour"]=>
  98. int(0)
  99. ["tm_mday"]=>
  100. int(1)
  101. ["tm_mon"]=>
  102. int(0)
  103. ["tm_year"]=>
  104. int(70)
  105. ["tm_wday"]=>
  106. int(4)
  107. ["tm_yday"]=>
  108. int(0)
  109. ["tm_isdst"]=>
  110. int(0)
  111. }
  112. --Hexa-decimal -10--
  113. array(9) {
  114. [0]=>
  115. int(50)
  116. [1]=>
  117. int(59)
  118. [2]=>
  119. int(23)
  120. [3]=>
  121. int(31)
  122. [4]=>
  123. int(11)
  124. [5]=>
  125. int(69)
  126. [6]=>
  127. int(3)
  128. [7]=>
  129. int(364)
  130. [8]=>
  131. int(0)
  132. }
  133. array(9) {
  134. ["tm_sec"]=>
  135. int(50)
  136. ["tm_min"]=>
  137. int(59)
  138. ["tm_hour"]=>
  139. int(23)
  140. ["tm_mday"]=>
  141. int(31)
  142. ["tm_mon"]=>
  143. int(11)
  144. ["tm_year"]=>
  145. int(69)
  146. ["tm_wday"]=>
  147. int(3)
  148. ["tm_yday"]=>
  149. int(364)
  150. ["tm_isdst"]=>
  151. int(0)
  152. }
  153. ===DONE===