normalize-date
Converts date from any format to native UTC JS Date. It is useful for further comparison
Note: This module works in browsers and Node.js >= 4.0
Installation
npm install normalize-date
Usage
const toDate = ; const date1 = ;const date2 = ;date1 === date2 //true const date3 = ;const date4 = ;date3 === date4 //true //Some of possible formats //ISO 8601 //ISO 8601 //ISO 8601 //RFC 2822 //RFC 2822 //the number of milliseconds since 1970 //UNIX timestamp //JS Date //arguments for Date constructor //MomentJS date
API
normalizeDate(date, [options])
-
date (
Any
) - Date as JS Date (or array with arguments), Moment, time, timestamp, ISO 8601, RFC 2822 -
options (
Object
) - Options- noTime (
Boolean
) - clear time
- noTime (
-
return (
Date
) - Native JavaScript Date (in UTC)
Tests
npm installnpm test