Date.fromString()

Construct a Date from a date String.

Signature

Date.fromString(dateString: String): Date

Description

The Date.fromString() method converts an ISO-8601 date String to a Date.

The method accepts only a date String and returns an error if time information is included in the String.

Date objects render to date strings in query responses.

This method is equivalent to the Date.fromString() method.

Parameters

Parameter Type Required Description

dateString

String

Yes

Date String in the form yyyy-MM-dd.

Return value

Type Description

Date

Date converted from string representation of the date.

Examples

Convert a date string to a Date:

Date.fromString("2022-10-20")
"2022-10-20"

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!