mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-21 02:37:43 -05:00
Signed-off-by: Janos <86970079+janosdebugs@users.noreply.github.com> Signed-off-by: Damian Stasik <920747+damianstasik@users.noreply.github.com> Signed-off-by: Roman Grinovski <roman.grinovski@gmail.com> Co-authored-by: Damian Stasik <920747+damianstasik@users.noreply.github.com> Co-authored-by: Roman Grinovski <roman.grinovski@gmail.com>
39 lines
1.1 KiB
Plaintext
39 lines
1.1 KiB
Plaintext
---
|
|
sidebar_label: timeadd
|
|
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 OpenTofu 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.
|
|
|
|
## Examples
|
|
|
|
```
|
|
> timeadd("2017-11-22T00:00:00Z", "10m")
|
|
2017-11-22T00:10:00Z
|
|
```
|
|
|
|
# Related Functions
|
|
|
|
* [`timecmp`](../../language/functions/timecmp.mdx) determines an ordering for two timestamps.
|