问题原文
原帖链接 · Brad · CC BY-SA 3.0
I'm trying to create a HTTP 1/1 compliant date header using standard unix date(1) in order to post this to a RESTful server using curl or similar.
Any ideas what format to pass to date(1) to get this to be RFC 1123 compliant?
Many thanks
社区高分解答
原帖链接 · Weihang Jian · CC BY-SA 4.0
env TZ=GMT; date '+%a, %d %b %Y %T %Z'
%Tis equivalent to%H:%M:%S.%Zis 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.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
