Chrono Node (chrono-node) is a natural language date and time parser for JavaScript, currently at version 2.9.0. It allows developers to extract and interpret date and time information from arbitrary text, supporting a wide range of formats including relative phrases ("tomorrow," "5 days ago"), absolute dates ("17 August 2013"), and date ranges ("Sep 12-13"). Since its v2 rewrite, the library is implemented in TypeScript, offering a more modular architecture with distinct parser and refiner interfaces. It differentiates itself by focusing on a performant, native JavaScript date/time core (having removed `dayjs` in v2.9.0) and providing robust control over parsing context, including explicit reference dates and timezones. While previous versions attempted to parse all known languages by default, v2.0.0 and later default to international English, requiring explicit configuration for other supported locales (e.g., Japanese, French, Dutch, Russian, Ukrainian).
npm install chrono-nodeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates basic date parsing, advanced parsing with a reference date and timezone, and the use of the `forwardDate` option for future-only interpretations. It also shows how to get detailed parsing results.
For non-English text, explicitly import and use the desired locale parser, e.g., `import { ja } from 'chrono-node'; ja.parseDate('...')` or `chrono.ja.parseDate('...')`. You can also create a custom Chrono instance with specific locales.Refactor custom components or code to use native JavaScript `Date` objects directly or other date utility libraries, as `chrono-node` now exclusively relies on native `Date` functionality.
Always provide a `ParsingReference` object with both `instant` (the current `Date` or a specific reference point) and `timezone` (e.g., 'America/New_York' or a minute offset) to ensure consistent and accurate parsing relative to a specific context.
If you consistently need dates to be in the future, explicitly set `{ forwardDate: true }` in the `ParsingOption` object when calling `chrono.parseDate` or `chrono.parse`.Review existing code that provides reference instants and relies on system timezone interpretations for relative dates. Ensure that the `timezone` property within `ParsingReference` accurately reflects the intended time context for your parsing operations.
Remove any calls to `ParsingComponent.dayjs()` or other `dayjs`-specific logic from your custom parsers or integrations. Refactor to use native JavaScript `Date` methods.
For ESM, use `import * as chrono from 'chrono-node';`. For CommonJS, use `const chrono = require('chrono-node');`. Ensure your build configuration (webpack, rollup, TypeScript `moduleResolution`) correctly handles module types.Pass the `forwardDate: true` option in the `ParsingOption` object: `chrono.parseDate('Friday', referenceDate, { forwardDate: true });`Always provide a comprehensive `ParsingReference` object with both `instant` (a `Date` object) and `timezone` (a string like 'America/Los_Angeles' or a minute offset) to ensure consistent timezone-aware parsing.
No dependency data recorded yet.