diff options
| author | Sterling Hughes <sterling@php.net> | 2001-12-14 11:43:20 +0000 |
|---|---|---|
| committer | Sterling Hughes <sterling@php.net> | 2001-12-14 11:43:20 +0000 |
| commit | a98c093d449218766618800cb14643ac69ed634e (patch) | |
| tree | d3acf6323fac38c6a3548459b9ef0978dc9d6f13 | |
| parent | 33f839f31d0d5dfd80cb4200af3b819364031aa3 (diff) | |
| download | php-git-a98c093d449218766618800cb14643ac69ed634e.tar.gz | |
be rfc compliant...
RFC 822 *only* supports four digits for the year in order to have a compliant
header.
RFC 850 supports two digits for the year (y2k_incompliant :) so use that when
y2k_compliance is turned off.
In either case, both of these formats require that GMT be appended to the header,
so we do this as well
| -rw-r--r-- | pear/HTTP.php | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/pear/HTTP.php b/pear/HTTP.php index b81cd0d6e3..594642c8bb 100644 --- a/pear/HTTP.php +++ b/pear/HTTP.php @@ -27,8 +27,7 @@ $GLOBALS['USED_PACKAGES']['HTTP'] = true; class HTTP { /** - * Format a date according to RFC-XXXX (can't remember the HTTP - * RFC number off-hand anymore, shame on me). This function + * Format a RFC compliant HTTP header. This function * honors the "y2k_compliance" php.ini directive. * * @param $time int UNIX timestamp @@ -36,10 +35,18 @@ class HTTP { * @return HTTP date string, or false for an invalid timestamp. * * @author Stig Bakken <ssb@fast.no> + * @author Sterling Hughes <sterling@php.net> */ function Date($time) { - $y = ini_get("y2k_compliance") ? "Y" : "y"; - return gmdate("D, d M $y H:i:s", $time); + /* If we're y2k compliant, use the newer, reccomended RFC 822 + format */ + if (ini_get("y2k_compliance") == true) { + return gmdate("D, d M Y H:i:s \G\M\T", $time); + } + /* Use RFC-850 which supports two character year numbers */ + else { + return gmdate("F, d-D-y H:i:s \G\M\T", $time); + } } /** |
