While playing with REDbot I realised my last-modified headers (being sent by PHP) were not RFC 1123 complaint. A complaint date looks like Sun, 06 Nov 1994 08:49:37 GMT
. There are two ways to generate such a date in PHP;
-
if you have pecl_http >= 0.1.0, then
http_date($timestamp)
-
or if you don’t want to use pecl
gmdate('D, d M Y H:i:s', $timestamp).' GMT'
-
or if you have PHP >5.2 you can use the DateTime constant
gmdate(DATE_RFC2822, $timestamp)
an example of it’s use:
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $lastModified).' GMT');