# normalize-date

> converts date from any format to native UTC JS Date

Latest version **0.0.4** (published 2018-04-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install normalize-date
pnpm add normalize-date
yarn add normalize-date
bun add normalize-date
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2018-04-10 |
| First published | 2016-09-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 0 |
| Unpacked size | 9.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Oleg Istomin |
| Maintainers | tamtakoe |
| Keywords | utc, date, time, timestamp, ISO8601, RFC2822, moment, normalize, convert |

## Links

- npm: https://www.npmjs.com/package/normalize-date
- Repository: https://github.com/tamtakoe/normalize-date
- Homepage: https://github.com/tamtakoe/normalize-date#readme
- Issues: https://github.com/tamtakoe/normalize-date/issues
- npm.io page: https://npm.io/package/normalize-date

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 0.0.4 (latest) — 2018-04-10
- 0.0.3 — 2016-09-05
- 0.0.2 — 2016-09-02
- 0.0.1 — 2016-09-02

## README

# normalize-date
Converts date from any format to native UTC JS Date. It is useful for further comparison

[![NPM version](https://img.shields.io/npm/v/normalize-date.svg)](https://npmjs.org/package/normalize-date)
[![Build status](https://img.shields.io/travis/tamtakoe/normalize-date.svg)](https://travis-ci.org/tamtakoe/normalize-date)

**Note:** This module works in browsers and Node.js >= 4.0


## Installation

```sh
npm install normalize-date
```


## Usage

```js
const toDate = require('normalize-date');

const date1 = toDate('2000-01-05T23:59:59.000Z');
const date2 = toDate('947116799.000');
date1.valueOf() === date2.valueOf() //true

const date3 = toDate('2000-01-05T23:59:59', {noTime: true});
const date4 = toDate(new Date(2000, 0, 5), {noTime: true});
date3.valueOf() === date4.valueOf() //true

//Some of possible formats
toDate('2000-01-05') //ISO 8601
toDate('2000-01-05T23:59:59Z') //ISO 8601
toDate('2000-01-05T23:59:59.000+00:00') //ISO 8601
toDate('Sat Jan 05 2000 23:59:59') //RFC 2822
toDate('Sat Jan 05 2000 22:59:59 GMT-0415') //RFC 2822
toDate(947116799000) //the number of milliseconds since 1970
toDate('947116799.000') //UNIX timestamp
toDate(new Date(2000, 0, 5, 23, 59, 59, 0)) //JS Date
toDate([2000, 0, 5, 23, 59, 59, 0]) //arguments for Date constructor
toDate(moment('2000-01-05T23:59:59.000')) //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

- **return** (`Date`) - Native JavaScript Date (in UTC)


## Tests

```sh
npm install
npm test
```

## License

[MIT](LICENSE)

---
_Source: https://npm.io/package/normalize-date · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
