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