The string to parse.
The parsed date or number of milliseconds.
InvalidInputError This exception is thrown if the input is invalid.
Here are some example invocations:
const ... = parse('1 day ago')
const ... = parse('three days ago')
const ... = parse('in 2 hours and 3 minutes')
const ... = parse('a month')
const ... = parse('2018-01-01')
const ... = parse('2018-01-01T00:00:00.000Z')
Here are some example invocations that throw an exception:
parse('in 2 hours and 3 minutes ago')
parse('a month in the past')
Parses a string into a
Date
or number of milliseconds. The string can describe the date in natural language (e.g. "tomorrow", "in 2 hours and 3 minutes", "a month ago", etc.) or be a valid date string (e.g. "2018-01-01").