---
title: Time
---
<BuiltinTable category={"time"}/>
:::info
Multiple calls to the `time.now_ns` built-in function within a single policy
evaluation query will always return the same value.
:::

Timezones can be specified as

- an [IANA Time Zone](https://www.iana.org/time-zones) string e.g. "America/New_York"
- "UTC" or "", which are equivalent to not passing a timezone (i.e. will return as UTC)
- "Local", which will use the local timezone.

Note that OPA will use the `time/tzdata` data if none is present on the runtime filesystem (see the
[Go `time.LoadLocation()`](https://pkg.go.dev/time#LoadLocation) documentation for more information).

#### Timestamp Parsing

OPA can parse timestamps of nearly arbitrary formats, and currently accepts the same inputs as Go's `time.Parse()` utility.
As a result, either you will pass a supported constant, or you **must** describe the format of your timestamps using the Reference Timestamp that Go's `time` module expects:

    2006-01-02T15:04:05Z07:00

In other date formats, that same value is rendered as:

- January 2, 15:04:05, 2006, in time zone seven hours west of GMT
- Unix time: `1136239445`
- Unix `date` command output: `Mon Jan 2 15:04:05 MST 2006`
- RFC3339 timestamp: `2006-01-02T15:04:05Z07:00`

Examples of valid values for each timestamp field:

- Year: `"2006"` `"06"`
- Month: `"Jan"` `"January"` `"01"` `"1"`
- Day of the week: `"Mon"` `"Monday"`
- Day of the month: `"2"` `"_2"` `"02"`
- Day of the year: `"__2"` `"002"`
- Hour: `"15"` `"3"` `"03"` (PM or AM)
- Minute: `"4"` `"04"`
- Second: `"5"` `"05"`
- AM/PM mark: `"PM"`

For supported constants, formatting of nanoseconds, time zones, and other fields, see the [Go `time/format` module documentation](https://cs.opensource.google/go/go/+/master:src/time/format.go;l=9-113).

<PlaygroundExample dir={require.context("../_examples/time/time_format")} />
