Epoch
Epoch( num, unit )
Epoch( num, unit )
Epoch( num, unit )
Epoch( num, unit )
epoch(0, unit )
Epoch( num, unit )
Description
The Epoch
function constructs a
Timestamp relative to the Unix epoch
(1970-01-01T00:00:00Z).
The num
argument must be an integer value. The unit
argument
specifies the scale of num
.
Parameters
Argument | Type | Definition and Requirements |
---|---|---|
|
A mathematical integer value specifying the offset from epoch. |
|
|
Indicates the units used by
|
Examples
The following query adds 0 seconds to the Unix epoch (1970-01-01T00:00:00Z) and returns a timestamp:
client.Query(Epoch(0, "second"));
{ "@ts": "1970-01-01T00:00:00Z" }
curl https://db.fauna.com/ \
-u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
-d '{ "epoch": 0, "unit": "second" }'
HTTP/1.1 200 OK
{ "resource": { "@ts": "1970-01-01T00:00:00Z" } }
result, _ := client.Query(f.Epoch(0, f.TimeUnitSecond))
fmt.Println(result)
{0 62135596800 <nil>}
System.out.println(
client.query(Epoch(Value(0), TimeUnit.SECOND))
.get());
1970-01-01T00:00:00Z
client.query(q.Epoch(0, 'second'))
.then((ret) => console.log(ret))
FaunaTime { value: '1970-01-01T00:00:00Z' }
client.query(q.epoch(0, "second"))
{ "@ts": "1970-01-01T00:00:00Z" }
client.query(Epoch(0, "second"))
{ "@ts": "1970-01-01T00:00:00Z" }
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!