mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
- Added 'c' modifier to date() which returns the date in ISO 8601 format.
This commit is contained in:
parent
9fc9e4b2cf
commit
e7fd0bdf03
2
NEWS
2
NEWS
@ -8,6 +8,8 @@ PHP NEWS
|
||||
. ext/db (Jani, Derick)
|
||||
. ext/mcal (Jani, Derick)
|
||||
. ext/qtdom (Jani, Derick)
|
||||
- Added 'c' modifier to date() which returns the date in the ISO 8601 format.
|
||||
(Derick, Manuzhai)
|
||||
- Added MacRoman encoding support to htmlentities(). (Derick, Marcus Bointon)
|
||||
- Added possibility to call PHP functions as XSLT-functions. (Christian)
|
||||
- Added possibility to prevent PHP from registering variables when input filter
|
||||
|
@ -331,6 +331,9 @@ static void php_date(INTERNAL_FUNCTION_PARAMETERS, int gm)
|
||||
case 'r': /* rfc822 format */
|
||||
size += 31;
|
||||
break;
|
||||
case 'c': /* iso8601 date (Dublin Core Date) */
|
||||
size += 25;
|
||||
break;
|
||||
case 'U': /* seconds since the epoch */
|
||||
size += 10;
|
||||
break;
|
||||
@ -557,8 +560,8 @@ static void php_date(INTERNAL_FUNCTION_PARAMETERS, int gm)
|
||||
strcat(Z_STRVAL_P(return_value), tmp_buff);
|
||||
break;
|
||||
case 'r':
|
||||
#if HAVE_TM_GMTOFF
|
||||
sprintf(tmp_buff, "%3s, %2d %3s %04d %02d:%02d:%02d %c%02d%02d",
|
||||
#if HAVE_TM_GMTOFF
|
||||
sprintf(tmp_buff, "%3s, %2d %3s %04d %02d:%02d:%02d %c%02d%02d",
|
||||
day_short_names[ta->tm_wday],
|
||||
ta->tm_mday,
|
||||
mon_short_names[ta->tm_mon],
|
||||
@ -571,7 +574,7 @@ static void php_date(INTERNAL_FUNCTION_PARAMETERS, int gm)
|
||||
abs( (ta->tm_gmtoff % 3600) / 60 )
|
||||
);
|
||||
#else
|
||||
sprintf(tmp_buff, "%3s, %2d %3s %04d %02d:%02d:%02d %c%02d%02d",
|
||||
sprintf(tmp_buff, "%3s, %2d %3s %04d %02d:%02d:%02d %c%02d%02d",
|
||||
day_short_names[ta->tm_wday],
|
||||
ta->tm_mday,
|
||||
mon_short_names[ta->tm_mon],
|
||||
@ -583,6 +586,34 @@ static void php_date(INTERNAL_FUNCTION_PARAMETERS, int gm)
|
||||
abs((ta->tm_isdst ? tzone - 3600 : tzone) / 3600),
|
||||
abs( ((ta->tm_isdst ? tzone - 3600 : tzone) % 3600) / 60 )
|
||||
);
|
||||
#endif
|
||||
strcat(Z_STRVAL_P(return_value), tmp_buff);
|
||||
break;
|
||||
case 'c':
|
||||
#if HAVE_TM_GMTOFF
|
||||
sprintf(tmp_buff, "%04d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d",
|
||||
ta->tm_year + YEAR_BASE,
|
||||
ta->tm_mon + 1,
|
||||
ta->tm_mday,
|
||||
ta->tm_hour,
|
||||
ta->tm_min,
|
||||
ta->tm_sec,
|
||||
(ta->tm_gmtoff < 0) ? '-' : '+',
|
||||
abs(ta->tm_gmtoff / 3600),
|
||||
abs( (ta->tm_gmtoff % 3600) / 60 )
|
||||
);
|
||||
#else
|
||||
sprintf(tmp_buff, "%04d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d",
|
||||
ta->tm_year + YEAR_BASE,
|
||||
ta->tm_mon + 1,
|
||||
ta->tm_mday,
|
||||
ta->tm_hour,
|
||||
ta->tm_min,
|
||||
ta->tm_sec,
|
||||
((ta->tm_isdst ? tzone - 3600 : tzone) > 0) ? '-' : '+',
|
||||
abs((ta->tm_isdst ? tzone - 3600 : tzone) / 3600),
|
||||
abs( ((ta->tm_isdst ? tzone - 3600 : tzone) % 3600) / 60 )
|
||||
);
|
||||
#endif
|
||||
strcat(Z_STRVAL_P(return_value), tmp_buff);
|
||||
break;
|
||||
|
22
ext/standard/tests/time/date.phpt
Normal file
22
ext/standard/tests/time/date.phpt
Normal file
@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
date() function
|
||||
--FILE--
|
||||
<?php
|
||||
$tmp = "cr";
|
||||
putenv ("TZ=GMT0");
|
||||
|
||||
for($a = 0;$a < strlen($tmp); $a++){
|
||||
echo $tmp{$a}, ': ', date($tmp{$a}, 1043324459)."\n";
|
||||
}
|
||||
|
||||
putenv ("TZ=MET");
|
||||
|
||||
for($a = 0;$a < strlen($tmp); $a++){
|
||||
echo $tmp{$a}, ': ', date($tmp{$a}, 1043324459)."\n";
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
c: 2003-01-23T12:20:59+00:00
|
||||
r: Thu, 23 Jan 2003 12:20:59 +0000
|
||||
c: 2003-01-23T13:20:59+01:00
|
||||
r: Thu, 23 Jan 2003 13:20:59 +0100
|
Loading…
Reference in New Issue
Block a user