Epoch

Epoch( num, unit )
Epoch( num, unit )
Epoch( num, unit )
Epoch( num, unit )
epoch(0, unit )
epoch  num, unit
Epoch( num, unit )
Epoch( num, unit )

Description

The Epoch function constructs a Timestamp relative to the epoch (1970-01-01T00:00:00Z). The num argument must be an integer value. The unit argument must be one of the following: "second", "millisecond", "microsecond", "nanosecond". Epoch adds num to offset defined in units and returns a timestamp.

Parameters

Argument Type Definition and Requirements

num

Number

A mathematical integer value specifying the offset from epoch.

unit

String

One of the following 4 strings "second", "millisecond", "microsecond", "nanosecond" indicating the units the offset is in.

Returns

A Timestamp which represents epoch plus the offset.

Examples

The query below adds 0 seconds to the epoch (1970-01-01T00:00:00Z) and returns a timestamp.

curl https://db.fauna.com/ \
    -u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
    -d '{ "epoch": 0, "unit": "second" }'
client.Query(Epoch(0, "second"));
System.out.println(
       client.query(Epoch(Value(0), TimeUnit.SECOND))
       .get());
result, _ := client.Query(f.Epoch(0, f.TimeUnitSecond))

fmt.Println(result)
client.query(Epoch(0, "second"))
client.query(q.epoch(0, "second"))
$client.query do
  epoch 0, 'second'
end
client.query(Epoch(0, "second"))
client.query(q.Epoch(0, "second"))
  .then((ret) => console.log(ret))
HTTP/1.1 200 OK
{ "resource": { "@ts": "1970-01-01T00:00:00Z" } }
{ "@ts": "1970-01-01T00:00:00Z" }
1970-01-01T00:00:00Z
{0 62135596800 <nil>}
{ "@ts": "1970-01-01T00:00:00Z" }
{ "@ts": "1970-01-01T00:00:00Z" }
{ "@ts": "1970-01-01T00:00:00Z" }
{ "@ts": "1970-01-01T00:00:00Z" }
FaunaTime { value: '1970-01-01T00:00:00Z' }

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve! documentation@fauna.com

Thank you for your feedback!