diff --git a/website/content/docs/templates/hcl_templates/functions/datetime/index.mdx b/website/content/docs/templates/hcl_templates/functions/datetime/index.mdx deleted file mode 100644 index 79438f886..000000000 --- a/website/content/docs/templates/hcl_templates/functions/datetime/index.mdx +++ /dev/null @@ -1,4 +0,0 @@ ---- -page_title: datetime - Functions - Configuration Language -description: Overview of available datetime functions ---- diff --git a/website/content/docs/templates/hcl_templates/functions/datetime/legacy_isotime.mdx b/website/content/docs/templates/hcl_templates/functions/datetime/legacy_isotime.mdx new file mode 100644 index 000000000..26db7c2fd --- /dev/null +++ b/website/content/docs/templates/hcl_templates/functions/datetime/legacy_isotime.mdx @@ -0,0 +1,41 @@ +--- +page_title: legacy_isotime - Functions - Configuration Language +description: |- + The legacy_isotime function returns a string representation of the current date + and time. +--- + +# `legacy_isotime` Function + +The `legacy_isotime` function returns the current date and time using the given format string. +The format string follows golang's datetime formatting. See +[isotime-function-format-reference](/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`](/docs/templates/hcl_templates/functions/datetime/timestamp) +and [`formatdate`](/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`](/docs/templates/hcl_templates/functions/string/format) is a more general formatting function for arbitrary +data. +- [`timestamp`](/docs/templates/hcl_templates/functions/datetime/timestamp) returns the current date and time in a format +suitable for input to `formatdate`. +- [`formatdate`](/docs/templates/hcl_templates/functions/datetime/formatdate) can convert the resulting timestamp to + other date and time formats. diff --git a/website/data/docs-nav-data.json b/website/data/docs-nav-data.json index 7b12f5b5d..5cd587a02 100644 --- a/website/data/docs-nav-data.json +++ b/website/data/docs-nav-data.json @@ -463,10 +463,6 @@ { "title": "Date and Time Functions", "routes": [ - { - "title": "Overview", - "path": "templates/hcl_templates/functions/datetime" - }, { "title": "formatdate", "path": "templates/hcl_templates/functions/datetime/formatdate" @@ -478,6 +474,10 @@ { "title": "timestamp", "path": "templates/hcl_templates/functions/datetime/timestamp" + }, + { + "title": "legacy_isotime", + "path": "templates/hcl_templates/functions/datetime/legacy_isotime" } ] },