You can use terraform timestamp() function to get the current time and date. timestamp() returns a UTC timestamp string in RFC 3339 format which can further be formatted using formatdate() function.
Syntax: timestamp()
Examples:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
## Open terraform console terraform console ## Get current timestamp timestamp() ## returns "2022-05-13T04:52:31Z" ## Get current date formatdate("YYYY-MMM-DD",timestamp()) ## returns "2022-May-13" ## Get current time formatdate("hh:mm:ss",timestamp()) ## returns "04:54:29" formatdate("hh:mmaa",timestamp()) ## returns "04:54am" |