---
page_title: legacy_isotime function reference
description: |-
  The `legacy_isotime` function returns a string representation of the current date
  and time. Learn how to use the `legacy_isotime` 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.
⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️

# `legacy_isotime` Function

The `legacy_isotime` function returns the current date and time using the given format string.
The format string follows Go's datetime formatting. See
[isotime-function-format-reference](/packer/docs/templates/legacy_json_templates/engine#isotime-function-format-reference)
for more details.

This function has been provided to create backwards compatibility with
Packer's legacy JSON templates. However, we recommend that you upgrade your
HCL Packer template to use [`timestamp`](/packer/docs/templates/hcl_templates/functions/datetime/timestamp)
and [`formatdate`](/packer/docs/templates/hcl_templates/functions/datetime/formatdate) together as soon as is convenient.

-> **Note:** If you are using a large number of builders, provisioners
or post-processors, the isotime may be slightly different for each one
because it is from when the plugin is launched not the initial Packer
process. In order to avoid this and make the timestamp consistent across all
plugins, set it as a user variable and then access the user variable within
your plugins.

## Examples

```shell-session
> legacy_isotime("2006-01-02")
2021-04-19
```

## Related Functions

- [`format`](/packer/docs/templates/hcl_templates/functions/string/format) is a more general formatting function for arbitrary
data.
- [`timestamp`](/packer/docs/templates/hcl_templates/functions/datetime/timestamp) returns the current date and time in a format
suitable for input to `formatdate`.
- [`formatdate`](/packer/docs/templates/hcl_templates/functions/datetime/formatdate) can convert the resulting timestamp to
  other date and time formats.
