From 4776f62caa36c580d24be8e55ebc6a61ae129f51 Mon Sep 17 00:00:00 2001 From: WeidiDeng Date: Tue, 22 Aug 2023 14:41:25 +0800 Subject: replacer: change timezone to UTC for "time.now.http" placeholders (#5774) --- replacer.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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": -- cgit v1.2.3