跳到正文
本页尚未翻译成中文,以下为英文原文。 查看英文版

rfc3339_parse function ​

The rfc3339_parse function parses an RFC 3339 timestamp string and returns an object with its date and time values.

hcl
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 ​

hcl
locals {
  timestamp = rfc3339_parse("2023-07-25T23:43:16Z")
  epoch     = local.timestamp.unix
}

The result includes the following attributes:

AttributeDescription
yearCalendar year.
year_dayDay of the year.
monthMonth number.
month_nameFull month name.
dayDay of the month.
weekdayDay of the week, where Sunday is 0.
weekday_nameFull weekday name.
hourHour in 24-hour time.
minuteMinute of the hour.
secondSecond of the minute.
unixUnix timestamp in seconds.
iso_yearISO 8601 week-numbering year.
iso_weekISO 8601 week number.

基于 MPL-2.0 许可证发布。