Skip to content

Commit 4776f62

Browse files
authored
replacer: change timezone to UTC for "time.now.http" placeholders (#5774)
1 parent 38a7b6b commit 4776f62

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

replacer.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,10 @@ func globalDefaultReplacements(key string) (any, bool) {
319319
case "time.now":
320320
return nowFunc(), true
321321
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
323326
case "time.now.common_log":
324327
return nowFunc().Format("02/Jan/2006:15:04:05 -0700"), true
325328
case "time.now.year":

0 commit comments

Comments
 (0)