Access the user’s local time and time zone in your functions
localtime
package from the SDK:
localtime
package are below.
All time zones use the IANA time zone database format. For example,
"America/New_York"
. You can find a list of valid time zones
here.
X-Time-Zone
header is present in the request, the time zone is set to
the value of the header.TZ
environment variable is set on the host, the time zone is set to
the value of the variable.modus dev
, Modus uses the host’s local time zone by
default. You can override this by setting the TZ
environment variable in your
.env.local
file."X-Time-Zone"
request header when calling Modus, to use
it for all local time calculations.time.Now()
function always
returns the UTC time, not the user’s local time like it usually does in Go. If
you need the user’s local time, use localtime.Now()
instead.time.Location
object for a specific time zone.
Errors if the time zone provided is invalid.
"America/New_York"
.time.Time
object, with the location set to the
user’s local time zone. Errors if the time zone passed to the host is invalid.
time.Time
object, with the location set to a
specific time zone. Errors if the time zone provided is invalid.
"America/New_York"
.