php-src/ext/date/tests/strftime_variation22.phpt

60 lines
1.5 KiB
Plaintext
Raw Normal View History

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");
}
2011-08-31 15:10:17 +08:00
if(!setlocale(LC_ALL, "POSIX")) {
die("skip Locale POSIX is needed by test and is not available");
2009-06-25 20:36:46 +08:00
}
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)
2011-08-31 15:10:17 +08:00
setlocale(LC_ALL, "POSIX");
putenv("LC_ALL=POSIX");
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"
2011-08-31 15:10:17 +08:00
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"
2011-08-31 15:10:17 +08:00
string(8) "08/08/08"
2009-01-21 18:51:04 +08:00
--Preferred time representation--
2011-01-24 10:48:15 +08:00
string(2) "%X"
2011-08-31 15:10:17 +08:00
string(8) "08:08:08"
2009-01-21 18:51:04 +08:00
===DONE===