Creating a RFC 1123 compliant date for HTTP header creation on the CLI
env TZ=GMT; date '+%a, %d %b %Y %T %Z'
%T
is equivalent to%H:%M:%S
.%Z
is replaced by the time zone name.
The solution by @brad, DATE=$(date -u +%a,\ %d\ %b\ %Y\ %H:%M:%S\ GMT)
, would be incorrect if the time zone setting of your system is not GMT. For example:
env TZ=Asia/Taipei; date -u +%a,\ %d\ %b\ %Y\ %H:%M:%S\ GMT
%H:%M:%S
would be GMT+8 while the output is GMT, but should be CST.