Skip to content

fromUnixTime

Description

Returns a parsed timestamp from a numeric Unix time value.

The Unix epoch starts on January 1, 1970. Timestamps before this are represented by negative numbers.

Syntax

Like many functions in DataPrime, fromUnixTime supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.

fromUnixTime(unixTime: number, timeUnit?: timeunit): timestamp
(unixTime: number).fromUnixTime(timeUnit?: timeunit): timestamp

Arguments

NameTypeRequiredDescription
unixTimenumbertrueThe Unix timestamp to convert
timeUnittimeunitfalseThe unit of the Unix timestamp. Defaults to milli

Example

Use case: Convert a numeric Unix timestamp to a proper timestamp

Interpret a numeric value as milliseconds since the epoch and convert it into a timestamp.

choose fromUnixTime(1658958157515, 'ms') as ts
choose 1658958157515.fromUnixTime('ms') as ts

Output

{
  "ts": 1658958157515000000
}