docs/content/en/functions/time/AsTime.md
Hugo provides functions and methods to format, localize, parse, compare, and manipulate date/time values. Before you can do any of these with string representations of date/time values, you must first convert them to time.Time values using the time.AsTime function.
{{ $t := "2023-10-15T13:18:50-07:00" }}
{{ time.AsTime $t }} → 2023-10-15 13:18:50 -0700 PDT (time.Time)
As shown above, the first argument must be a parsable string representation of a date/time value. For example:
{{% include "/_common/parsable-date-time-strings.md" %}}
To override the default time zone, set the timeZone in your project configuration or provide a second argument to the time.AsTime function. For example:
{{ time.AsTime "15 Oct 2023" "America/Los_Angeles" }}
The list of valid time zones may be system dependent, but should include UTC, Local, or any location in the IANA Time Zone database.
The order of precedence for determining the time zone is:
time.AsTime functionEtc/UTC time zone