Hcl2 input variables, local variables and functions (#8588)
Mainly redefine or reused what Terraform did.
* allow to used `variables`, `variable` and `local` blocks
* import the following functions and their docs from Terraform: abs, abspath, basename, base64decode, base64encode, bcrypt, can, ceil, chomp, chunklist, cidrhost, cidrnetmask, cidrsubnet, cidrsubnets, coalesce, coalescelist, compact, concat, contains, convert, csvdecode, dirname, distinct, element, file, fileexists, fileset, flatten, floor, format, formatdate, formatlist, indent, index, join, jsondecode, jsonencode, keys, length, log, lookup, lower, max, md5, merge, min, parseint, pathexpand, pow, range, reverse, rsadecrypt, setintersection, setproduct, setunion, sha1, sha256, sha512, signum, slice, sort, split, strrev, substr, timestamp, timeadd, title, trim, trimprefix, trimspace, trimsuffix, try, upper, urlencode, uuidv4, uuidv5, values, yamldecode, yamlencode, zipmap.
2020-02-06 11:49:21 +01:00
|
|
|
---
|
2020-03-18 18:46:47 -04:00
|
|
|
page_title: timeadd - Functions - Configuration Language
|
2020-04-02 19:39:47 -04:00
|
|
|
sidebar_title: timeadd
|
Hcl2 input variables, local variables and functions (#8588)
Mainly redefine or reused what Terraform did.
* allow to used `variables`, `variable` and `local` blocks
* import the following functions and their docs from Terraform: abs, abspath, basename, base64decode, base64encode, bcrypt, can, ceil, chomp, chunklist, cidrhost, cidrnetmask, cidrsubnet, cidrsubnets, coalesce, coalescelist, compact, concat, contains, convert, csvdecode, dirname, distinct, element, file, fileexists, fileset, flatten, floor, format, formatdate, formatlist, indent, index, join, jsondecode, jsonencode, keys, length, log, lookup, lower, max, md5, merge, min, parseint, pathexpand, pow, range, reverse, rsadecrypt, setintersection, setproduct, setunion, sha1, sha256, sha512, signum, slice, sort, split, strrev, substr, timestamp, timeadd, title, trim, trimprefix, trimspace, trimsuffix, try, upper, urlencode, uuidv4, uuidv5, values, yamldecode, yamlencode, zipmap.
2020-02-06 11:49:21 +01:00
|
|
|
description: |-
|
|
|
|
The timeadd function adds a duration to a timestamp, returning a new
|
|
|
|
timestamp.
|
|
|
|
---
|
|
|
|
|
|
|
|
# `timeadd` Function
|
|
|
|
|
|
|
|
`timeadd` adds a duration to a timestamp, returning a new timestamp.
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
timeadd(timestamp, duration)
|
|
|
|
```
|
|
|
|
|
|
|
|
In the Packer language, timestamps are conventionally represented as
|
|
|
|
strings using [RFC 3339](https://tools.ietf.org/html/rfc3339)
|
|
|
|
"Date and Time format" syntax. `timeadd` requires the `timestamp` argument
|
|
|
|
to be a string conforming to this syntax.
|
|
|
|
|
|
|
|
`duration` is a string representation of a time difference, consisting of
|
|
|
|
sequences of number and unit pairs, like `"1.5h"` or `"1h30m"`. The accepted
|
|
|
|
units are `"ns"`, `"us"` (or `"µs"`), `"ms"`, `"s"`, `"m"`, and `"h"`. The first
|
|
|
|
number may be negative to indicate a negative duration, like `"-2h5m"`.
|
|
|
|
|
|
|
|
The result is a string, also in RFC 3339 format, representing the result
|
|
|
|
of adding the given direction to the given timestamp.
|
|
|
|
|
|
|
|
-> **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
|
2021-01-15 09:18:39 -08:00
|
|
|
format" syntax. As a string. [`formatdate`](/docs/templates/hcl_templates/functions/datetime/formatdate) still allows you
|
Hcl2 input variables, local variables and functions (#8588)
Mainly redefine or reused what Terraform did.
* allow to used `variables`, `variable` and `local` blocks
* import the following functions and their docs from Terraform: abs, abspath, basename, base64decode, base64encode, bcrypt, can, ceil, chomp, chunklist, cidrhost, cidrnetmask, cidrsubnet, cidrsubnets, coalesce, coalescelist, compact, concat, contains, convert, csvdecode, dirname, distinct, element, file, fileexists, fileset, flatten, floor, format, formatdate, formatlist, indent, index, join, jsondecode, jsonencode, keys, length, log, lookup, lower, max, md5, merge, min, parseint, pathexpand, pow, range, reverse, rsadecrypt, setintersection, setproduct, setunion, sha1, sha256, sha512, signum, slice, sort, split, strrev, substr, timestamp, timeadd, title, trim, trimprefix, trimspace, trimsuffix, try, upper, urlencode, uuidv4, uuidv5, values, yamldecode, yamlencode, zipmap.
2020-02-06 11:49:21 +01:00
|
|
|
to format a date.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
2020-05-29 17:12:05 -04:00
|
|
|
```shell-session
|
Hcl2 input variables, local variables and functions (#8588)
Mainly redefine or reused what Terraform did.
* allow to used `variables`, `variable` and `local` blocks
* import the following functions and their docs from Terraform: abs, abspath, basename, base64decode, base64encode, bcrypt, can, ceil, chomp, chunklist, cidrhost, cidrnetmask, cidrsubnet, cidrsubnets, coalesce, coalescelist, compact, concat, contains, convert, csvdecode, dirname, distinct, element, file, fileexists, fileset, flatten, floor, format, formatdate, formatlist, indent, index, join, jsondecode, jsonencode, keys, length, log, lookup, lower, max, md5, merge, min, parseint, pathexpand, pow, range, reverse, rsadecrypt, setintersection, setproduct, setunion, sha1, sha256, sha512, signum, slice, sort, split, strrev, substr, timestamp, timeadd, title, trim, trimprefix, trimspace, trimsuffix, try, upper, urlencode, uuidv4, uuidv5, values, yamldecode, yamlencode, zipmap.
2020-02-06 11:49:21 +01:00
|
|
|
> timeadd("2017-11-22T00:00:00Z", "10m")
|
|
|
|
2017-11-22T00:10:00Z
|
|
|
|
```
|