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

num

A mathematical integer value specifying the offset from epoch.

unit

Indicates the units used by num. Must be one of:

  • day, or days

  • half day, or half days

  • hour, or hours

  • minute, or minutes

  • second, or seconds

  • millisecond, or milliseconds

  • microsecond, or microseconds

  • nanosecond, or nanoseconds

Returns

A Timestamp which represents Unix epoch plus the offset represented by num and unit.

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")
);
FaunaTime(1970-01-01T00:00:00Z)
result, err := client.Query(
	f.Epoch(0, f.TimeUnitSecond))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	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))
.catch((err) => console.error('Error: %s', err))
Time("1970-01-01T00:00:00Z")
result = client.query(
  q.epoch(0, "second")
)
print(result)
FaunaTime('1970-01-01T00:00:00Z')
client.query(Epoch(0, "second"))
1970-01-01T00:00:00Z

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve!
Visit Fauna's Discourse forums or email docs@fauna.com

Thank you for your feedback!