2009-01-21 18:51:04 +08:00
|
|
|
--TEST--
|
|
|
|
Test strftime() function : usage variation - Checking Preferred date and time representation other than on Windows.
|
|
|
|
--SKIPIF--
|
|
|
|
<?php
|
|
|
|
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
|
|
|
|
die("skip Test is not valid for Windows");
|
|
|
|
}
|
2009-06-25 20:36:46 +08:00
|
|
|
if(!setlocale(LC_ALL, "en_US.utf8", "en_US")) {
|
|
|
|
die("skip Locale en_US.utf8 or en_US is needed by test and is not available");
|
|
|
|
}
|
2009-01-21 18:51:04 +08:00
|
|
|
?>
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
/* Prototype : string strftime(string format [, int timestamp])
|
|
|
|
* Description: Format a local time/date according to locale settings
|
|
|
|
* Source code: ext/date/php_date.c
|
|
|
|
* Alias to functions:
|
|
|
|
*/
|
|
|
|
|
|
|
|
echo "*** Testing strftime() : usage variation ***\n";
|
|
|
|
|
|
|
|
// Initialise function arguments not being substituted (if any)
|
2009-01-27 22:22:17 +08:00
|
|
|
setlocale(LC_ALL, "en_US.utf8", "en_US");
|
2009-01-21 18:51:04 +08:00
|
|
|
date_default_timezone_set("Asia/Calcutta");
|
|
|
|
$timestamp = mktime(8, 8, 8, 8, 8, 2008);
|
|
|
|
|
|
|
|
//array of values to iterate over
|
|
|
|
$inputs = array(
|
|
|
|
'Preferred date and time representation' => "%c",
|
|
|
|
'Preferred date representation' => "%x",
|
|
|
|
'Preferred time representation' => "%X",
|
|
|
|
);
|
|
|
|
|
|
|
|
// loop through each element of the array for timestamp
|
|
|
|
|
|
|
|
foreach($inputs as $key =>$value) {
|
|
|
|
echo "\n--$key--\n";
|
2011-01-24 10:48:15 +08:00
|
|
|
var_dump( $value );
|
2009-01-21 18:51:04 +08:00
|
|
|
var_dump( strftime($value, $timestamp) );
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
===DONE===
|
2011-01-24 10:48:15 +08:00
|
|
|
--EXPECT--
|
2009-01-21 18:51:04 +08:00
|
|
|
*** Testing strftime() : usage variation ***
|
|
|
|
|
|
|
|
--Preferred date and time representation--
|
2011-01-24 10:48:15 +08:00
|
|
|
string(2) "%c"
|
|
|
|
string(24) "Fri Aug 8 08:08:08 2008"
|
2009-01-21 18:51:04 +08:00
|
|
|
|
|
|
|
--Preferred date representation--
|
2011-01-24 10:48:15 +08:00
|
|
|
string(2) "%x"
|
2009-01-21 18:51:04 +08:00
|
|
|
string(10) "08/08/2008"
|
|
|
|
|
|
|
|
--Preferred time representation--
|
2011-01-24 10:48:15 +08:00
|
|
|
string(2) "%X"
|
|
|
|
string(8) "08:08:08"
|
2009-01-21 18:51:04 +08:00
|
|
|
===DONE===
|