Company
Date Published
Author
Nora Mullen
Word count
644
Language
English
Hacker News points
None

Summary

In Flux, two timestamp formats are available: Unix timestamp and RFC3339 timestamp. The Unix timestamp format counts time since the Unix Epoch (1970-01-01T00:00:00Z UTC) in specified units such as nanoseconds, microseconds, milliseconds, seconds, etc. To convert timestamps from Unix nanoseconds to a human readable RFC3339 timestamp, use the `time()` function, and vice versa with `uint()`. Flux does not support mathematical operations using time type values, so to calculate duration between two timestamps, it is necessary to convert them to Unix nanosecond format first, then subtract one from another, and finally apply `duration()` function. The current time can be retrieved using the `now()` function in UTC or by importing the system package and `system.time()` function for RFC3339 format.