added system.time to manipulating timestamps guide, resolves #564

pull/568/head
Scott Anderson 2019-10-30 10:20:36 -06:00
parent 66b59331bf
commit 2454eaf74c
1 changed files with 21 additions and 1 deletions

View File

@ -59,7 +59,7 @@ to convert the duration to a string.
## Time-related Flux functions
### Retrieve the current time
### Retrieve the current UTC time
Use the [`now()` function](/v2.0/reference/flux/stdlib/built-in/misc/now/) to
return the current UTC time in RFC3339 format.
@ -67,6 +67,26 @@ return the current UTC time in RFC3339 format.
now()
```
{{% note %}}
`now()` is cached at runtime, so all instances of `now()` in a Flux script
return the same value.
{{% /note %}}
### Retrieve the current system time
Import the `system` package and use the [`system.time()` function](/v2.0/reference/flux/stdlib/system/time/)
to return the current system time of the host machine in RFC3339 format.
```js
import "system"
system.time()
```
{{% note %}}
`system.time()` returns the time it is executed, so each instance of `system.time()`
in a Flux script returns a unique value.
{{% /note %}}
### Add a duration to a timestamp
The [`experimental.addDuration()` function](/v2.0/reference/flux/stdlib/experimental/addduration/)
adds a duration to a specified time and returns the resulting time.