mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
website: Docs for all of the Date and Time functions
This commit is contained in:
parent
a35c0f3cbf
commit
46f8208727
36
website/docs/configuration/functions/timeadd.html.md
Normal file
36
website/docs/configuration/functions/timeadd.html.md
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
layout: "functions"
|
||||||
|
page_title: "timeadd function"
|
||||||
|
sidebar_current: "docs-funcs-datetime-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 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
|
||||||
|
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
|
||||||
|
```
|
35
website/docs/configuration/functions/timestamp.html.md
Normal file
35
website/docs/configuration/functions/timestamp.html.md
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
---
|
||||||
|
layout: "functions"
|
||||||
|
page_title: "timestamp function"
|
||||||
|
sidebar_current: "docs-funcs-datetime-timestamp"
|
||||||
|
description: |-
|
||||||
|
The timestamp function returns a string representation of the current date
|
||||||
|
and time.
|
||||||
|
---
|
||||||
|
|
||||||
|
# `timestamp` Function
|
||||||
|
|
||||||
|
`timestamp` returns the current date and time.
|
||||||
|
|
||||||
|
In the Terraform language, timestamps are conventionally represented as
|
||||||
|
strings using [RFC 3339](https://tools.ietf.org/html/rfc3339)
|
||||||
|
"Date and Time format" syntax, and so `timestamp` returns a string
|
||||||
|
in this format.
|
||||||
|
|
||||||
|
The result of this function will change every second, so using this function
|
||||||
|
directly with resource attributes will cause a diff to be detected on every
|
||||||
|
Terraform run. We do not recommend using this function in resource attributes,
|
||||||
|
but in rare cases it can be used in conjunction with
|
||||||
|
[the `ignore_changes` lifecycle meta-argument](/docs/configuration/resources.html#ignore_changes)
|
||||||
|
to take the timestamp only on initial creation of the resource.
|
||||||
|
|
||||||
|
Due to the constantly changing return value, the result of this function cannot
|
||||||
|
be preducted during Terraform's planning phase, and so the timestamp will be
|
||||||
|
taken only once the plan is being applied.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
```
|
||||||
|
> timestamp()
|
||||||
|
2018-05-13T07:44:12Z
|
||||||
|
```
|
Loading…
Reference in New Issue
Block a user