I am working on a service which returns expires header. The service will be working across different timezone. So we need a way to return other timezones than GMT.
I know that the http header have to follow RFC1123 standard date format. So the service returns date like below -
Fri, 01 Mar 2019 15:00:00 GMT
What I need is return the date in below format.
Fri, 01 Mar 2019 15:00:00 +0530
Is this a valid date for RFC1123 date format?
I guess you are using the old and obsolete RFC 2616 as reference. Please bear in mind that such document is no longer relevant nowadays and has been replaced with the following documents:
According to the RFC 7231, HTTP dates must be expressed in GMT. So expressing dates with offsets from UTC don't seem to be valid valid.
See how the Expires
header is defined in the RFC 7234:
The
Expires
header field gives the date/time after which the response is considered stale. [...]The
Expires
value is anHTTP-date
timestamp, as defined in Section 7.1.1.1 of RFC 7231.Expires = HTTP-date
For example
Expires: Thu, 01 Dec 1994 16:00:00 GMT
Now see the following quote from the RFC 7231:
Prior to 1995, there were three different formats commonly used by servers to communicate timestamps. For compatibility with old implementations, all three are defined here. The preferred format is a fixed-length and single-zone subset of the date and time specification used by the Internet Message Format [RFC5322].
HTTP-date = IMF-fixdate / obs-date
An example of the preferred format is
Sun, 06 Nov 1994 08:49:37 GMT ; IMF-fixdate
Examples of the two obsolete formats are
Sunday, 06-Nov-94 08:49:37 GMT ; obsolete RFC 850 format Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format
A recipient that parses a timestamp value in an HTTP header field MUST accept all three
HTTP-date
formats. When a sender generates a header field that contains one or more timestamps defined asHTTP-date
, the sender MUST generate those timestamps in theIMF-fixdate
format.An HTTP-date value represents time as an instance of Coordinated Universal Time (UTC). The first two formats indicate UTC by the three-letter abbreviation for Greenwich Mean Time, GMT, a predecessor of the UTC name; values in the
asctime
format are assumed to be in UTC. [...]