--- title: "toDate" description: "Tries to coerce value into a Date." --- # toDate > Tries to coerce value into a Date. **This function is used by Ignition's Expression language**. ## Description Tries to coerce value into a date. If value is a number or a string that represents a number, the number is treated as the number of milliseconds since the epoch, January 1, 1970, 00:00:00 GMT. If value is a string, it is parsed to see if it represents a date in one of the supported formats: * yyyy-MM-dd * MM/dd/yyyy * MM/dd/yyyy HH:mm:ss * hh:mm:ss a * hh:mm a * MM/dd/yyyy hh:mm:ss a * yyyy-MM-dd HH:mm:ss.SSS * yyyy-MM-dd HH:mm:ss * EEE MMM dd HH:mm:ss z yyyy * yyyyMMdd.HHmmssSSSZ If not, type casting fails.The failover value must be a number or string with the same restrictions. ## Syntax `toDate(value, [failover])` ### Parameters | Type | Parameter | Description | |---|---|---| | Object | `value` | The value to type cast into a date. | | Object | `failover` | The failover value if type casting fails. [optional] | ### Results **Date** - The value type cast as a date. ## Examples ```python title="Code Snippet" toDate("2007-04-12 16:28:22") //returns April 12th, 2007, 4:28:22 PM ```