valid-moment
v1.0.0
Published
Convert standard date string to Date, based on moment.js; and invalidate bad formatting
Downloads
11
Maintainers
Readme
valid-moment
Convert standard date string to Date, based on moment.js; and invalidate bad formatting.
https://stackoverflow.com/questions/7445328/check-if-a-string-is-a-date-value
Examples
Valid date strings include,
- ISO 8601 date strings (from JavaScript, Python or Java)
- RFC 2822 date strings
- Locale string
Invalid date string include,
- Numbers and number strings
Plans
Usage
import { toDate, toMoment } from "valid-moment";
console.log(toDate(DATE_STRING)) // Returns 'null' if invalid
console.log(toMoment(DATE_STRING)) // Returns 'null' if invalid
Installation
npm i valid-moment
Tests
For current testing results, see /tests/tests.json. The tests are done at GMT+0700.