# `gtime`, `ltime`

_Global and local time_

The `TZ` environment variable sets the local time zone. The examples on this page set it with [`setenv`](getenv.md#setenv) so that their results don't depend on where you run them.

## `gtime`

_UTC equivalent of local timestamp_
```syntax
gtime ts    gtime[ts]
```

Where `ts` is a local datetime or timestamp, returns the corresponding UTC datetime or timestamp.
```q
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_
```syntax
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
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`](dotz.md#zz-utc-datetime) | [`.z.p`](dotz.md#zp-utc-timestamp) |
| Local | [`.z.Z`](dotz.md#zz-local-datetime) | [`.z.P`](dotz.md#zp-local-timestamp) |

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.

----

[Environment](by-topic.md#environment)
