Time

Time( str )
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. 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.

ISO 8601 times

Time uses Java’s Date/Time API which understands a subset of the ISO 8601 standard. Not all time strings that are ISO 8601-compliant can be parsed.

The template for times is yyyy-MM-ddThh:mm:ssTZO, where:

  • yyyy represents the year

  • MM represents the month, from 00 to 12

  • dd represents the day, from 00 to 31

  • T is a separator between the date and time

  • hh represents the hours, from 00 to 23

  • mm represents the minutes, from 00 to 59

  • ss represents the seconds, from 00 to 59

  • TZO is the timezone offset from GMT, which can be:

    • Z for GMT (no offset)

    • +hhmm for a positive hour and minute offset from GMT

    • -hhmm for a negative hour and minute offset from GMT

The seconds can also be expressed as a decimal fraction, which provides down to nanosecond resolution.

Parameters

Argument Type Definition and Requirements

str

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

Returns

A Timestamp based on the value of str.

Examples

The following query returns a Timestamp constructed from the provided string:

try
{
    Value result = await client.Query(
        Time("1970-01-01T00:00:00+00:00")
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
FaunaTime(1970-01-01T00:00:00Z)
result, err := client.Query(
	f.Time("1970-01-01T00:00:00+00:00"))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	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))
.catch((err) => console.error('Error: %s', err))
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')
try {
  println(Await.result(
  client.query(Time("1970-01-01T00:00:00+00:00")),
  5.seconds
))} catch {
  case unknown: Throwable => println("Error: " + unknown.getMessage())
}
1970-01-01T00:00:00Z
Time('1970-01-01T00:00:00+00:00')
Time("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!