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

Parameter 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] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
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')
ToTime('2020-07-06T12:34:56.789Z')
Time("2020-07-06T12:34:56.789Z")
Query metrics:
  •    bytesIn:  38

  •   bytesOut:  47

  • computeOps:   1

  •    readOps:   0

  •   writeOps:   0

  •  readBytes:   0

  • writeBytes:   0

  •  queryTime: 2ms

  •    retries:   0

Was this article helpful? 

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

Thank you for your feedback!