ToTime

ToTime( value )
ToTime( value )
ToTime( value )
ToTime( value )
to_time( value )
ToTime( value )

Description

The ToTime function converts a value to a timestamp, if possible.

Attempting to convert a value to a timestamp which has no timestamp representation results in an "invalid argument" error.

Parameters

Argument Type Definition and Requirements

value

Any

The value to attempt to convert to a Timestamp.

Returns

A Timestamp created by interpreting value.

Examples

The following query converts the string "2015-02-20T06:30:00Z" to a timestamp:

try
{
    Value result = await client.Query(
        ToTime("2015-02-20T06:30:00Z")
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
FaunaTime(2015-02-20T06:30:00Z)
result, err := client.Query(
	f.ToTime("2015-02-20T06:30:00Z"))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
{0 63560010600 <nil>}
System.out.println(
    client.query(
        ToTime(Value("2015-02-20T06:30:00Z"))
    ).get());
2015-02-20T06:30:00Z
client.query(
  q.ToTime('2020-07-06T12:34:56.789Z')
)
.then((ret) => console.log(ret))
.catch((err) => console.error('Error: %s', err))
Time("2020-07-06T12:34:56.789Z")
result = client.query(
  q.to_time('2015-02-20T06:30:00Z')
)
print(result)
FaunaTime('2015-02-20T06:30:00Z')
try {
  println(Await.result(
  client.query(
    ToTime("2015-02-20T06:30:00Z")
  ),
  5.seconds
))} catch {
  case unknown: Throwable => println("Error: " + unknown.getMessage())
}
2015-02-20T06:30: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!