summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWeidiDeng <weidi_deng@icloud.com>2023-08-22 14:41:25 +0800
committerGitHub <noreply@github.com>2023-08-22 02:41:25 -0400
commit4776f62caa36c580d24be8e55ebc6a61ae129f51 (patch)
treeaa2293ac46cd6bfe967aa5ff4b9a91bf308fc997
parent38a7b6b3d0e1150bc22e2f5409b74821132f8741 (diff)
replacer: change timezone to UTC for "time.now.http" placeholders (#5774)
-rw-r--r--replacer.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/replacer.go b/replacer.go
index 817bcfe..5d33b7f 100644
--- a/replacer.go
+++ b/replacer.go
@@ -319,7 +319,10 @@ func globalDefaultReplacements(key string) (any, bool) {
case "time.now":
return nowFunc(), true
case "time.now.http":
- return nowFunc().Format(http.TimeFormat), true
+ // According to the comment for http.TimeFormat, the timezone must be in UTC
+ // to generate the correct format.
+ // https://github.com/caddyserver/caddy/issues/5773
+ return nowFunc().UTC().Format(http.TimeFormat), true
case "time.now.common_log":
return nowFunc().Format("02/Jan/2006:15:04:05 -0700"), true
case "time.now.year":