parse Function

Top  Previous  Next

Parses a string representing a date and/or time.

Syntax

DateTime.parse(string)

Arguments

stringA string to parse for date and/or time.

Return Value

An integer that is the date/time value for the date and time parsed from the string, or NaN (not a number) if string is not a valid date/time.

Remarks

string can include just a date, just a time, or both a date and time.

Examples

All the following are valid:

DateTime.parse("8 am")

DateTime.parse("8:15")

DateTime.parse("8:15:20")

DateTime.parse("19:30")

DateTime.parse("7:30PM")

DateTime.parse("7:30:55 pm")

DateTime.parse("December 5, 2011")

DateTime.parse("Dec 5 2011")

DateTime.parse("12/5/2011")

DateTime.parse("12-5-11")

DateTime.parse("5 Dec 2011")

DateTime.parse("2011 Dec 5")

DateTime.parse("2011-12-5")

DateTime.parse("12/5/11 8am")

DateTime.parse("Dec 5, 2011 7:30 pm")

DateTime.parse("5 December 2011 8:15am")