github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/website/docs/configuration/functions/timestamp.html.md (about)

     1  ---
     2  layout: "functions"
     3  page_title: "timestamp - Functions - Configuration Language"
     4  sidebar_current: "docs-funcs-datetime-timestamp"
     5  description: |-
     6    The timestamp function returns a string representation of the current date
     7    and time.
     8  ---
     9  
    10  # `timestamp` Function
    11  
    12  -> **Note:** This page is about Terraform 0.12 and later. For Terraform 0.11 and
    13  earlier, see
    14  [0.11 Configuration Language: Interpolation Syntax](../../configuration-0-11/interpolation.html).
    15  
    16  `timestamp` returns the current date and time.
    17  
    18  In the Terraform language, timestamps are conventionally represented as
    19  strings using [RFC 3339](https://tools.ietf.org/html/rfc3339)
    20  "Date and Time format" syntax, and so `timestamp` returns a string
    21  in this format.
    22  
    23  The result of this function will change every second, so using this function
    24  directly with resource attributes will cause a diff to be detected on every
    25  Terraform run. We do not recommend using this function in resource attributes,
    26  but in rare cases it can be used in conjunction with
    27  [the `ignore_changes` lifecycle meta-argument](../resources.html#ignore_changes)
    28  to take the timestamp only on initial creation of the resource.
    29  
    30  Due to the constantly changing return value, the result of this function cannot
    31  be predicted during Terraform's planning phase, and so the timestamp will be
    32  taken only once the plan is being applied.
    33  
    34  ## Examples
    35  
    36  ```
    37  > timestamp()
    38  2018-05-13T07:44:12Z
    39  ```
    40  
    41  ## Related Functions
    42  
    43  * [`formatdate`](./formatdate.html) can convert the resulting timestamp to
    44    other date and time formats.