Time

Time( str )
Time( str )
Time( str )
Time( str )
Time( str )
Time( str )

Description

The Time function constructs a Timestamp, either from the string now, or from an ISO 8601 string.

The special string now may be used to construct a time from the transaction’s start time. Multiple references to now within the same transaction produce the same timestamp. The transaction’s start time is the same on all nodes that participate in the transaction. During a temporal query, now still means the transaction’s start time, not the temporal query’s specified timestamp.

Use of now is deprecated. Use Now instead.

Parameters

Argument Type Definition and Requirements

str

The string now, or an ISO 8601 date/time formatted string.

Returns

A Timestamp which represents the converted string.

Examples

The query below returns a Timestamp constructed from the provided string.

client.Query(Time("1970-01-01T00:00:00+00:00"));
{ "@ts": "1970-01-01T00:00:00Z" }
curl https://db.fauna.com/ \
    -u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
    -d '{ "time": "1970-01-01T00:00:00+00:00" }'
HTTP/1.1 200 OK
{ "resource": { "@ts": "1970-01-01T00:00:00Z" } }
result, _ := client.Query(f.Time("1970-01-01T00:00:00+00:00"))
fmt.Println(result)
{0 62135596800 <nil>}
System.out.println(
    client.query(
        Time(Value("1970-01-01T00:00:00+00:00"))
    ).get()
);
1970-01-01T00:00:00Z
client.query(q.Time('1970-01-01T00:00:00+00:00'))
.then((ret) => console.log(ret))
Time("1970-01-01T00:00:00Z")
result = client.query(q.time("1970-01-01T00:00:00+00:00"))
print(result)
FaunaTime('1970-01-01T00:00:00Z')
println(Await.result(
  client.query(Time("1970-01-01T00:00:00+00:00")),
  5.seconds
))
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!