getdate_variation6.phpt 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. --TEST--
  2. Test getdate() function : usage variation - Passing strings containing numbers
  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. date_default_timezone_set("Asia/Calcutta");
  12. //Timezones with required data for date_sunrise
  13. $inputs = array (
  14. 'String 0' => '0',
  15. 'String 10.5' => "10.5",
  16. 'String -10.5' => '-10.5',
  17. );
  18. // loop through each element of the array for timestamp
  19. foreach($inputs as $key => $value) {
  20. echo "\n--$key--\n";
  21. var_dump( getdate($value) );
  22. };
  23. ?>
  24. ===DONE===
  25. --EXPECTF--
  26. *** Testing getdate() : usage variation ***
  27. --String 0--
  28. array(11) {
  29. ["seconds"]=>
  30. int(0)
  31. ["minutes"]=>
  32. int(30)
  33. ["hours"]=>
  34. int(5)
  35. ["mday"]=>
  36. int(1)
  37. ["wday"]=>
  38. int(4)
  39. ["mon"]=>
  40. int(1)
  41. ["year"]=>
  42. int(1970)
  43. ["yday"]=>
  44. int(0)
  45. ["weekday"]=>
  46. string(8) "Thursday"
  47. ["month"]=>
  48. string(7) "January"
  49. [0]=>
  50. int(0)
  51. }
  52. --String 10.5--
  53. array(11) {
  54. ["seconds"]=>
  55. int(10)
  56. ["minutes"]=>
  57. int(30)
  58. ["hours"]=>
  59. int(5)
  60. ["mday"]=>
  61. int(1)
  62. ["wday"]=>
  63. int(4)
  64. ["mon"]=>
  65. int(1)
  66. ["year"]=>
  67. int(1970)
  68. ["yday"]=>
  69. int(0)
  70. ["weekday"]=>
  71. string(8) "Thursday"
  72. ["month"]=>
  73. string(7) "January"
  74. [0]=>
  75. int(10)
  76. }
  77. --String -10.5--
  78. array(11) {
  79. ["seconds"]=>
  80. int(50)
  81. ["minutes"]=>
  82. int(29)
  83. ["hours"]=>
  84. int(5)
  85. ["mday"]=>
  86. int(1)
  87. ["wday"]=>
  88. int(4)
  89. ["mon"]=>
  90. int(1)
  91. ["year"]=>
  92. int(1970)
  93. ["yday"]=>
  94. int(0)
  95. ["weekday"]=>
  96. string(8) "Thursday"
  97. ["month"]=>
  98. string(7) "January"
  99. [0]=>
  100. int(-10)
  101. }
  102. ===DONE===