A utility package for guessing a date string's format and outputting it as either moment.js format tokens or strftime format tokens. Current version 1.2.4. It relies on moment.js and date-and-time parsers to tokenize input, then applies refiners and assigners to produce the best guess. Useful for developers who need to reverse-engineer a date format from an example string. Unlike other date detection libraries, it supports moment.js and strftime output and handles ambiguous input by returning all possible matches. The package is maintained but has low release cadence.
npm install moment-guessNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to guess date format from a string using moment-guess, including default and strftime outputs, and handling ambiguous input.
Always handle the result as either a string or an array of strings.
Wrap calls in try-catch or validate input beforehand.
Check the list of supported tokens in documentation or use default format as fallback.
Use CommonJS require: const guessFormat = require('moment-guess');Ensure the date string follows supported formats (ISO 8601, RFC 2822, slash/dot/dash separated, month-name variants).
Use import * as guessFormat from 'moment-guess' or const guessFormat = require('moment-guess').default;