Hugo currently has no provision for converting time values from one location to another. If it’s 4:20 PM in Vancouver, Hugo has no idea what time it is in Kiev.
The time.AsTime
TIMEZONE
parameter is only useful for dates without offsets. The TIMEZONE
parameter qualifies dates without offsets, adding an offset and time zone abbreviation.
If the date already has an offset, the TIMEZONE
parameter is ignored.
Assuming you have not set a fallback timeZone
in your site configuration…
Code | Output |
---|---|
{{ time.AsTime "2022-12-11T22:36:09" }} |
2022-12-11 22:36:09 +0000 UTC |
{{ time.AsTime "2022-12-11T22:36:09" "Europe/Kyiv" }} |
2022-12-11 22:36:09 +0200 EET |
{{ time.AsTime "2022-12-11T22:36:09-08:00" "Europe/Kyiv" }} |
2022-12-11 22:36:09 -0800 PST |
{{ time.AsTime now "Europe/Kyiv" }} |
2022-12-11 22:50:03 -0800 PST |
Adding the TIMEZONE
makes no difference for dates with offsets (including what the now
function returns).