Date and Time Functions
The following section will cover the most common date and time functions supported by Terraform 1.5.x. The examples used in the section will be available with the filename 3. date-and-time-functions.txt
in the GitHub link provided at the start of this chapter.
The timestamp() Function
The timestamp()
function returns the current date and time in the UTC format as per RFC 3339 specifications. This is the same format used internally by Terraform where the timestamps are used; hence, this function also returns with the same syntax.
Here is the syntax:
timestamp()
An example is as follows:
$ timestamp()
"2024-03-09T17:03:03Z" ("YYYY-MM-DDTHH:MM:SSZ")
Note
The output will vary based on when the function was tried out.
The formatdate() Function
The formatdate()
function converts the given timestamp into a different date and time format. For more details on the possible format sequences, please refer to the official...