strptime_basic.phpt 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. --TEST--
  2. Test strptime() function : basic functionality
  3. --SKIPIF--
  4. <?php
  5. if (!function_exists('strptime')) {
  6. die("skip - strptime() function not available in this build");
  7. }
  8. if (PHP_OS_FAMILY == 'Darwin' || PHP_OS_FAMILY == 'BSD') {
  9. die("skip strptime() behaves differently on Darwin/BSD");
  10. }
  11. if (!@strftime('%Z')) die('skip strftime does not support %Z');
  12. ?>
  13. --FILE--
  14. <?php
  15. $orig = setlocale(LC_ALL, 'C');
  16. date_default_timezone_set("GMT");
  17. echo "*** Testing strptime() : basic functionality ***\n";
  18. $input = "10:00:00 AM July 2 1963";
  19. $tstamp = strtotime($input);
  20. $str = strftime("%r %B%e %Y %Z", $tstamp);
  21. var_dump(strptime($str, '%H:%M:%S %p %B %d %Y'));
  22. $str = strftime("%T %D", $tstamp);
  23. var_dump(strptime($str, '%H:%M:%S %m/%d/%y'));
  24. $str = strftime("%A %B %e %R", $tstamp);
  25. var_dump(strptime($str, '%A %B %e %R'));
  26. setlocale(LC_ALL, $orig);
  27. ?>
  28. --EXPECTF--
  29. *** Testing strptime() : basic functionality ***
  30. Deprecated: Function strftime() is deprecated in %s on line %d
  31. Deprecated: Function strptime() is deprecated in %s on line %d
  32. array(9) {
  33. ["tm_sec"]=>
  34. int(0)
  35. ["tm_min"]=>
  36. int(0)
  37. ["tm_hour"]=>
  38. int(10)
  39. ["tm_mday"]=>
  40. int(2)
  41. ["tm_mon"]=>
  42. int(6)
  43. ["tm_year"]=>
  44. int(63)
  45. ["tm_wday"]=>
  46. int(2)
  47. ["tm_yday"]=>
  48. int(182)
  49. ["unparsed"]=>
  50. string(4) " GMT"
  51. }
  52. Deprecated: Function strftime() is deprecated in %s on line %d
  53. Deprecated: Function strptime() is deprecated in %s on line %d
  54. array(9) {
  55. ["tm_sec"]=>
  56. int(0)
  57. ["tm_min"]=>
  58. int(0)
  59. ["tm_hour"]=>
  60. int(10)
  61. ["tm_mday"]=>
  62. int(2)
  63. ["tm_mon"]=>
  64. int(6)
  65. ["tm_year"]=>
  66. int(163)
  67. ["tm_wday"]=>
  68. int(1)
  69. ["tm_yday"]=>
  70. int(182)
  71. ["unparsed"]=>
  72. string(0) ""
  73. }
  74. Deprecated: Function strftime() is deprecated in %s on line %d
  75. Deprecated: Function strptime() is deprecated in %s on line %d
  76. array(9) {
  77. ["tm_sec"]=>
  78. int(0)
  79. ["tm_min"]=>
  80. int(0)
  81. ["tm_hour"]=>
  82. int(10)
  83. ["tm_mday"]=>
  84. int(2)
  85. ["tm_mon"]=>
  86. int(6)
  87. ["tm_year"]=>
  88. int(0)
  89. ["tm_wday"]=>
  90. int(2)
  91. ["tm_yday"]=>
  92. int(182)
  93. ["unparsed"]=>
  94. string(0) ""
  95. }