Forum Discussion
crafting a RFC1123 timestamp for Date header in an iRule
for crafting a HTTP response i the need a timestamp in RFC 1123 format for the Date header.
example: Thu, 24 Nov 2016 19:34:09 GMT
i was able to get most of it within a clock format line
set rfc1123_time [clock format [clock seconds] -format "%a, %d %b %Y %H:%M:%S %Z"]
but the timezone should be in GMT, with adding -gmt 0 (not -timestamp as i found in some documentation) it changes the time correctly but the time zone from %Z becomes UTC and not GMT
set rfc1123_time [clock format [clock seconds] -gmt 0 -format "%a, %d %b %Y %H:%M:%S %Z"]
for now i went the easy way, dropped the timezone part from the clock format and added GMT in text.
any iRule wizards know how to do this more nicely? so one clock format that returns the requested string.
1 Reply
Hi Boneyard,
I'm using the syntax below to generate RFC1123 timestamps.
[clock format [clock seconds] -format "%a, %d %h %Y %T GMT" -gmt 1]
Note:
is a bolean value to enable|disable GMT/UTC timezone. So make sure to use-gmt (0|1)
.-gmt 1
Cheers, Kai
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com