2018-05-13 21:49:05 +02:00
|
|
|
---
|
2020-08-15 03:51:06 +02:00
|
|
|
layout: "language"
|
2018-12-20 05:35:11 +01:00
|
|
|
page_title: "timeadd - Functions - Configuration Language"
|
2018-05-13 21:49:05 +02:00
|
|
|
sidebar_current: "docs-funcs-datetime-timeadd"
|
|
|
|
description: |-
|
|
|
|
The timeadd function adds a duration to a timestamp, returning a new
|
|
|
|
timestamp.
|
|
|
|
---
|
|
|
|
|
|
|
|
# `timeadd` Function
|
|
|
|
|
2019-01-17 01:33:57 +01:00
|
|
|
-> **Note:** This page is about Terraform 0.12 and later. For Terraform 0.11 and
|
|
|
|
earlier, see
|
|
|
|
[0.11 Configuration Language: Interpolation Syntax](../../configuration-0-11/interpolation.html).
|
|
|
|
|
2018-05-13 21:49:05 +02:00
|
|
|
`timeadd` adds a duration to a timestamp, returning a new timestamp.
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
timeadd(timestamp, duration)
|
|
|
|
```
|
|
|
|
|
|
|
|
In the Terraform 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
|
2019-03-19 19:23:24 +01:00
|
|
|
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
|
2018-05-13 21:49:05 +02:00
|
|
|
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.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
```
|
|
|
|
> timeadd("2017-11-22T00:00:00Z", "10m")
|
|
|
|
2017-11-22T00:10:00Z
|
|
|
|
```
|