gtime, ltime¶
Global and local time
The TZ environment variable sets the local time zone. The examples on this page set it with setenv so that their results don't depend on where you run them.
gtime¶
UTC equivalent of local timestamp
gtime ts gtime[ts]
Where ts is a local datetime or timestamp, returns the corresponding UTC datetime or timestamp.
q)`TZ setenv "America/New_York"
q)gtime 2026.11.04D12:00:00.000000000
2026.11.04D17:00:00.000000000
q)gtime 2026.11.04T12:00:00.000
2026.11.04T17:00:00.000
ltime¶
Local equivalent of UTC timestamp
ltime ts ltime[ts]
Where ts is a UTC datetime or timestamp, returns the corresponding local datetime or timestamp.
ltime accounts for daylight saving time.
q)`TZ setenv "America/New_York"
q)ltime 2026.11.04D12:00:00 2026.07.01D12:00:00 / winter and summer
2026.11.04D07:00:00.000000000 2026.07.01D08:00:00.000000000
System clocks¶
These system variables return UTC and local datetimes and timestamps:
| Scope | Datetime | Timestamp |
|---|---|---|
| UTC | .z.z |
.z.p |
| Local | .z.Z |
.z.P |
So gtime .z.P is the same as .z.p, and ltime .z.p is the same as .z.P, apart from the time between the calls.