Date & Time
Overview
NCL represents time using Unix time: the number of seconds since the Unix epoch, 1970-01-01T00:00:00Z.
The processor provides the current Unix time through TIME. Calendar operations are provided by the Time coprocessor through the T.* interface.
All date and time operations use UTC. The Time coprocessor does not provide time zones, daylight-saving rules, locale information, or localized names.
A fixed offset can be applied by adding or subtracting seconds from a Unix timestamp before passing it to a T.* verb.
Unix timestamps are signed 32-bit integers. The representable range is:
| Limit | Unix time | UTC date and time |
|---|---|---|
| Minimum | -2147483648 |
1901-12-13T20:45:52Z |
| Maximum | 2147483647 |
2038-01-19T03:14:07Z |
Processor Time
TIME — Current Unix Time
TIME <dst>
Stores the current Unix time in the destination location.
Unix time is the number of whole seconds since 1970-01-01T00:00:00Z.
Operands
| Position | Name | Type | Description |
|---|---|---|---|
| 1 | dst |
Integer location | Destination location. |
Modified locations
| Location | Description |
|---|---|
dst |
Current Unix time. |
Examples
-- Read the current time.
TIME $000
-- > $000 = 1780273354
Notes
TIMEis a processor instruction and does not use the Time coprocessor.- Resolution is one second.
- The returned value is always UTC Unix time.
Time Coprocessor
The Time coprocessor interprets and converts Unix timestamps.
It does not maintain its own clock. Each operation acts on the timestamp supplied by the program. Use TIME when the current time is required.
TIME $000
T.YEAR $001 $000
Because the timestamp is supplied explicitly, the time required to communicate with the coprocessor does not affect the value being interpreted.
T.YEAR — Year
T.YEAR <dst> <time>
Stores the Gregorian calendar year containing the supplied Unix timestamp.
Operands
| Position | Name | Type | Description |
|---|---|---|---|
| 1 | dst |
Integer location | Destination. |
| 2 | time |
Integer value | Unix timestamp. |
Modified locations
| Location | Description |
|---|---|
dst |
Calendar year. |
Examples
T.YEAR $001 0
-- > $001 = 1970
T.MONTH — Month
T.MONTH <dst> <time>
Stores the month containing the supplied Unix timestamp.
Months are numbered 1 through 12, where January is 1.
Operands
| Position | Name | Type | Description |
|---|---|---|---|
| 1 | dst |
Integer location | Destination. |
| 2 | time |
Integer value | Unix timestamp. |
Modified locations
| Location | Description |
|---|---|
dst |
Month number, 1–12. |
Examples
T.MONTH $001 0
-- > $001 = 1
T.DAY — Day of Month
T.DAY <dst> <time>
Stores the day of the month containing the supplied Unix timestamp.
Days are numbered starting at 1.
Operands
| Position | Name | Type | Description |
|---|---|---|---|
| 1 | dst |
Integer location | Destination. |
| 2 | time |
Integer value | Unix timestamp. |
Modified locations
| Location | Description |
|---|---|
dst |
Day of month. |
Examples
T.DAY $001 0
-- > $001 = 1
T.HOUR — Hour
T.HOUR <dst> <time>
Stores the UTC hour containing the supplied Unix timestamp.
Hours are numbered 0 through 23.
Operands
| Position | Name | Type | Description |
|---|---|---|---|
| 1 | dst |
Integer location | Destination. |
| 2 | time |
Integer value | Unix timestamp. |
Modified locations
| Location | Description |
|---|---|
dst |
Hour, 0–23. |
Examples
T.HOUR $001 0
-- > $001 = 0
T.MIN — Minute
T.MIN <dst> <time>
Stores the minute containing the supplied Unix timestamp.
Minutes are numbered 0 through 59.
Operands
| Position | Name | Type | Description |
|---|---|---|---|
| 1 | dst |
Integer location | Destination. |
| 2 | time |
Integer value | Unix timestamp. |
Modified locations
| Location | Description |
|---|---|
dst |
Minute, 0–59. |
Examples
T.MIN $001 0
-- > $001 = 0
T.SEC — Second
T.SEC <dst> <time>
Stores the second containing the supplied Unix timestamp.
Seconds are numbered 0 through 59.
Operands
| Position | Name | Type | Description |
|---|---|---|---|
| 1 | dst |
Integer location | Destination. |
| 2 | time |
Integer value | Unix timestamp. |
Modified locations
| Location | Description |
|---|---|
dst |
Second, 0–59. |
Examples
T.SEC $001 0
-- > $001 = 0
T.WDAY — Day of Week
T.WDAY <dst> <time>
Stores the day of the week containing the supplied Unix timestamp.
Days are numbered 0 through 6:
| Value | Day |
|---|---|
0 |
Sunday |
1 |
Monday |
2 |
Tuesday |
3 |
Wednesday |
4 |
Thursday |
5 |
Friday |
6 |
Saturday |
Operands
| Position | Name | Type | Description |
|---|---|---|---|
| 1 | dst |
Integer location | Destination. |
| 2 | time |
Integer value | Unix timestamp. |
Modified locations
| Location | Description |
|---|---|
dst |
Day of week, 0–6. |
Examples
-- 1970-01-01 was a Thursday.
T.WDAY $001 0
-- > $001 = 4
T.YDAY — Day of Year
T.YDAY <dst> <time>
Stores the zero-based day of the year containing the supplied Unix timestamp.
January 1 is day 0. The final day of the year is 364 in a common year and 365 in a leap year.
Operands
| Position | Name | Type | Description |
|---|---|---|---|
| 1 | dst |
Integer location | Destination. |
| 2 | time |
Integer value | Unix timestamp. |
Modified locations
| Location | Description |
|---|---|
dst |
Day of year, 0–365. |
Examples
T.YDAY $001 0
-- > $001 = 0
T.LEAP — Leap-Year Distance
T.LEAP <dst> <year>
Stores the number of years since the most recent Gregorian leap year.
A leap year itself returns 0. Years following it return the number of years elapsed since that leap year.
Operands
| Position | Name | Type | Description |
|---|---|---|---|
| 1 | dst |
Integer location | Destination. |
| 2 | year |
Integer value | Gregorian year. |
Modified locations
| Location | Description |
|---|---|
dst |
Years since the most recent leap. |
Examples
T.LEAP $000 2024
-- > $000 = 0
T.LEAP $000 2025
-- > $000 = 1
T.LEAP $000 2026
-- > $000 = 2
T.LEAP $000 2027
-- > $000 = 3
T.LEAP $000 2028
-- > $000 = 0
Notes
- Leap years follow the Gregorian calendar.
- A year divisible by
4is normally a leap year. - A year divisible by
100is not a leap year unless it is also divisible by400. - Because of skipped century leap years, the result is not limited to
0–3.
For example:
T.LEAP $000 2100
-- > $000 = 4
T.LEAP $000 2103
-- > $000 = 7
T.LEAP $000 2104
-- > $000 = 0
T.ISO — ISO Timestamp
T.ISO <dst> <time>
Converts a Unix timestamp to an ISO 8601 UTC timestamp.
The resulting string has the form:
YYYY-MM-DDTHH:MM:SSZ
Operands
| Position | Name | Type | Description |
|---|---|---|---|
| 1 | dst |
String location | Destination. |
| 2 | time |
Integer value | Unix timestamp. |
Modified locations
| Location | Description |
|---|---|
dst |
ISO timestamp. |
Examples
T.ISO $001 0
-- > $001 = "1970-01-01T00:00:00Z"
TIME $000
T.ISO $001 $000
-- > $001 = current UTC time in ISO format
Notes
- Output is always UTC.
- Resolution is one second.
- No fractional-second component is produced.
- No time-zone offset other than
Zis produced.
T.UNIX — Unix Timestamp
T.UNIX <dst> <iso>
Converts an ISO 8601 UTC timestamp to Unix time.
Operands
| Position | Name | Type | Description |
|---|---|---|---|
| 1 | dst |
Integer location | Destination. |
| 2 | iso |
String value | ISO UTC timestamp. |
Modified locations
| Location | Description |
|---|---|
dst |
Unix timestamp. |
Examples
T.UNIX $000 "1970-01-01T00:00:00Z"
-- > $000 = 0
T.UNIX $000 "2026-09-30T23:48:15Z"
T.ISO $001 $000
-- > $001 = "2026-09-30T23:48:15Z"
Notes
T.UNIX accepts timestamps in the following form:
YYYY-MM-DDTHH:MM:SSZ
The timestamp is interpreted as UTC.
The resulting Unix timestamp must fit within the signed 32-bit Unix time range.