rfc3339_parse function
The rfc3339_parse function parses an RFC 3339 timestamp string and returns an object with
its date and time values.
rfc3339_parse(TIMESTAMP)
The function accepts timestamps that use either T or a space between the date
and time. For example, both 2023-07-25T23:43:16Z and 2023-07-25 23:43:16Z are valid timestamps.
The function also accepts timestamps with optional fractional seconds.
Example
locals {
timestamp = rfc3339_parse("2023-07-25T23:43:16Z")
epoch = local.timestamp.unix
}
The result includes the following attributes:
| Attribute | Description |
|---|---|
year | Calendar year. |
year_day | Day of the year. |
month | Month number. |
month_name | Full month name. |
day | Day of the month. |
weekday | Day of the week, where Sunday is 0. |
weekday_name | Full weekday name. |
hour | Hour in 24-hour time. |
minute | Minute of the hour. |
second | Second of the minute. |
unix | Unix timestamp in seconds. |
iso_year | ISO 8601 week-numbering year. |
iso_week | ISO 8601 week number. |
Related functions
unix_timestamp_parseconverts a Unix timestamp into date and time values.formatdateformats an RFC 3339 timestamp string.