github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/docs/job-specification/hcl2/functions/datetime/timeadd.mdx (about)

     1  ---
     2  layout: docs
     3  page_title: timeadd - Functions - Configuration Language
     4  description: |-
     5    The timeadd function adds a duration to a timestamp, returning a new
     6    timestamp.
     7  ---
     8  
     9  # `timeadd` Function
    10  
    11  `timeadd` adds a duration to a timestamp, returning a new timestamp.
    12  
    13  ```hcl
    14  timeadd(timestamp, duration)
    15  ```
    16  
    17  In the Nomad language, timestamps are conventionally represented as
    18  strings using [RFC 3339](https://tools.ietf.org/html/rfc3339)
    19  "Date and Time format" syntax. `timeadd` requires the `timestamp` argument
    20  to be a string conforming to this syntax.
    21  
    22  `duration` is a string representation of a time difference, consisting of
    23  sequences of number and unit pairs, like `"1.5h"` or `"1h30m"`. The accepted
    24  units are `"ns"`, `"us"` (or `"µs"`), `"ms"`, `"s"`, `"m"`, and `"h"`. The first
    25  number may be negative to indicate a negative duration, like `"-2h5m"`.
    26  
    27  The result is a string, also in RFC 3339 format, representing the result
    28  of adding the given direction to the given timestamp.
    29  
    30  ## Examples
    31  
    32  ```shell-session
    33  > timeadd("2017-11-22T00:00:00Z", "10m")
    34  2017-11-22T00:10:00Z
    35  ```