How to get GMT time by using time.format #430
Answered
by
anderseknert
JinXiu2023
asked this question in
OPA and Rego
-
hello, I want to get a RFC822/RFC1123 time and the time zone is GMT standard time like This is the code. package example
date1 := time.format(time.now_ns())
date2 := time.format([time.now_ns(), "Asia/Shanghai"])
date3 := time.format([time.now_ns(), "", "RFC1123"])
date4 := time.format([time.now_ns(), "", "%a,%d%b%Y %H:%M:%S GMT"]) This is the answer. {
"date1": "2023-05-24T03:50:39.596970532Z",
"date2": "2023-05-24T11:50:39.596970532+08:00",
"date3": "RFC55243",
"date4": "%a,%d%b%Y %H:%M:%S GMT"
} |
Beta Was this translation helpful? Give feedback.
Answered by
anderseknert
May 24, 2023
Replies: 1 comment 1 reply
-
Good morning! Yeah, ideally you'd be able to use some of the predefined layouts for formatting, but for now you'll have to use the reference format as defined in Golang, i.e:
See https://gosamples.dev/date-time-format-cheatsheet/ for some alternatives. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
JinXiu2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good morning! Yeah, ideally you'd be able to use some of the predefined layouts for formatting, but for now you'll have to use the reference format as defined in Golang, i.e:
See https://gosamples.dev/date-time-format-cheatsheet/ for some alternatives.