---
page_title: timestamp function reference
description: |-
  The `timestamp` function returns a string representation of the current date
  and time. Learn how to use the `timestamp` function in Packer templates.
---

⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
> [!IMPORTANT]  
> **Documentation Update:** Product documentation previously located in `/website` has moved to the [`hashicorp/web-unified-docs`](https://github.com/hashicorp/web-unified-docs) repository, where all product documentation is now centralized. Please make contributions directly to `web-unified-docs`, since changes to `/website` in this repository will not appear on developer.hashicorp.com.
⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️

# `timestamp` Function

`timestamp` returns the current date and time.

In the Packer language, timestamps are conventionally represented as
strings using [RFC 3339](https://tools.ietf.org/html/rfc3339)
"Date and Time format" syntax, and so `timestamp` returns a string
in this format.

The result of this function will change every second, so using this function
directly with resource attributes will cause a diff to be detected on every
Packer run.

-> **Breaking change note:** Packer previously let you decide your own "Date
and Time format" syntax. With HCL2 and for parity with Terraform, Packer will
be using the [RFC 3339](https://tools.ietf.org/html/rfc3339) "Date and Time
format" syntax. As a string. [`formatdate`](/packer/docs/templates/hcl_templates/functions/datetime/formatdate) still allows you
to format a date.

## Examples

```shell-session
> timestamp()
2018-05-13T07:44:12Z
```

## Related Functions

- [`formatdate`](/packer/docs/templates/hcl_templates/functions/datetime/formatdate) can convert the resulting timestamp to
  other date and time formats.
