1--TEST-- 2Test 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?> 9--FILE-- 10<?php 11/* Prototype : array strptime ( string $date , string $format ) 12 * Description: Parse a time/date generated with strftime() 13 * Source code: ext/standard/datetime.c 14*/ 15 16$orig = setlocale(LC_ALL, 'C'); 17date_default_timezone_set("GMT"); 18putenv("TZ=GMT"); 19 20echo "*** Testing strptime() : basic functionality ***\n"; 21 22$input = "10:01:20 AM July 2 1963"; 23$tstamp = strtotime($input); 24 25$str = strftime("%r %B%e %Y %Z", $tstamp); 26$res = strptime($str, '%H:%M:%S %p %B %d %Y %Z'); 27var_dump($res["tm_sec"]); 28var_dump($res["tm_min"]); 29var_dump($res["tm_hour"]); 30var_dump($res["tm_mday"]); 31var_dump($res["tm_mon"]); 32var_dump($res["tm_year"]); 33 34$str = strftime("%T %D", $tstamp); 35$res = strptime($str, '%H:%M:%S %m/%d/%y'); 36var_dump($res["tm_sec"]); 37var_dump($res["tm_min"]); 38var_dump($res["tm_hour"]); 39var_dump($res["tm_mday"]); 40var_dump($res["tm_mon"]); 41var_dump($res["tm_year"]); 42 43$str = strftime("%A %B %e %R", $tstamp); 44$res = strptime($str, '%A %B %e %R'); 45var_dump($res["tm_sec"]); 46var_dump($res["tm_min"]); 47var_dump($res["tm_hour"]); 48var_dump($res["tm_mday"]); 49var_dump($res["tm_mon"]); 50var_dump($res["tm_year"]); 51 52setlocale(LC_ALL, $orig); 53?> 54===DONE=== 55--EXPECT-- 56*** Testing strptime() : basic functionality *** 57int(20) 58int(1) 59int(10) 60int(2) 61int(6) 62int(63) 63int(20) 64int(1) 65int(10) 66int(2) 67int(6) 68int(163) 69int(0) 70int(1) 71int(10) 72int(2) 73int(6) 74int(0) 75===DONE=== 76