@marcel91200 / caddy Mirror · read-only / commits / 4776f62c
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 12, 23:15 UTC

replacer: change timezone to UTC for "time.now.http" placeholders (#5774)

WeidiDeng committed Aug 22, 2023 at 14:41 UTC 4776f62caa36c580d24be8e55ebc6a61ae129f51
1 file changed +4 -1
replacer.go
+4 -1
@@ -319,7 +319,10 @@ func globalDefaultReplacements(key string) (any, bool) {
319 case "time.now":
320 return nowFunc(), true
321 case "time.now.http":
322 - return nowFunc().Format(http.TimeFormat), true
322 + // According to the comment for http.TimeFormat, the timezone must be in UTC
323 + // to generate the correct format.
324 + // https://github.com/caddyserver/caddy/issues/5773
325 + return nowFunc().UTC().Format(http.TimeFormat), true
326 case "time.now.common_log":
327 return nowFunc().Format("02/Jan/2006:15:04:05 -0700"), true
328 case "time.now.year":