1--TEST-- 2Test gmstrftime() function : usage variation - Passing time related format strings to format argument. 3--FILE-- 4<?php 5echo "*** Testing gmstrftime() : usage variation ***\n"; 6 7// Initialise function arguments not being substituted (if any) 8$timestamp = gmmktime(8, 8, 8, 8, 8, 2008); 9setlocale(LC_ALL, "en_US"); 10date_default_timezone_set("Asia/Calcutta"); 11 12//array of values to iterate over 13$inputs = array( 14 'Hour as decimal by 24-hour format' => "%H", 15 'Hour as decimal by 12-hour format' => "%I", 16 'Minute as decimal number' => "%M", 17 'AM/PM format for a time' => "%p", 18 'Second as decimal number' => "%S", 19); 20 21// loop through each element of the array for timestamp 22 23foreach($inputs as $key =>$value) { 24 echo "\n--$key--\n"; 25 var_dump( gmstrftime($value) ); 26 var_dump( gmstrftime($value, $timestamp) ); 27}; 28 29?> 30--EXPECTF-- 31*** Testing gmstrftime() : usage variation *** 32 33--Hour as decimal by 24-hour format-- 34string(2) "%d" 35string(2) "08" 36 37--Hour as decimal by 12-hour format-- 38string(2) "%d" 39string(2) "08" 40 41--Minute as decimal number-- 42string(%d) "%d" 43string(2) "08" 44 45--AM/PM format for a time-- 46string(2) "%s" 47string(2) "AM" 48 49--Second as decimal number-- 50string(%d) "%d" 51string(2) "08" 52