The date string to parse (e.g., "2023-01-05", "25.12.2023", "Jan 15, 2023")
Array of all possible interpretations, each with timestamp, format, and optionally months, sorted by format priority (see compareDateFormatOrder function)
For year-month only dates (no day component), the result includes a months
property
representing the number of months since 1970-01 (where 1970-01 = 0, 1970-02 = 1, etc.).
parseDateString('2023-01-05')
// [
// { timestamp: 1672876800000, format: 'Y-M2-D2' }, // Jan 5, 2023
// { timestamp: 1683763200000, format: 'Y-D2-M2' } // May 1, 2023
// ]
parseDateString('25.12.2023')
// [{ timestamp: 1703462400000, format: 'D1.M1.Y' }] // Dec 25, 2023
parseDateString('Dec 25, 2023')
// [{ timestamp: 1703462400000, format: 'Ms D1, Y' }] // Dec 25, 2023
parseDateString('2023-12')
// [{ timestamp: 1701388800000, format: 'Y-M1', months: 647 }] // Dec 1, 2023, 647 months since 1970-01
parseDateString('Jan 2024')
// [{ timestamp: 1704067200000, format: 'Ms Y', months: 648 }] // Jan 1, 2024, 648 months since 1970-01
Parses a date string and returns all possible interpretations with their corresponding timestamps. Each ambiguous date string may have multiple valid interpretations, each with its own timestamp. Supports various date formats including Y-M-D, D-M-Y, M-D-Y, Y-M, M-Y, M-D, D-M. Separators can be "-", ".", "/", ",", or ", ".
Default values: