# date-format-helper

> Date Format Helper

Latest version **0.0.1** (published 2020-10-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install date-format-helper
pnpm add date-format-helper
yarn add date-format-helper
bun add date-format-helper
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2020-10-03 |
| First published | 2020-09-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | cifer |
| Maintainers | cifergit |
| Keywords | date-format-helper, date-format, date-helper, format-helper |

## Links

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

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2020-10-03
- 0.0.1-beta.1 — 2020-09-30

## README

# date-format-helper
This is a simple date format component

## Install

```
npm install --save date-format-helper
```

## Usage

ES Modules
```javascript
import { dateFormat } from 'format-date-helper'
```
CommonJS
```javascript
const { dateFormat } = require('format-date-helper')
```

Html in Browser that support ES Modules
```html
<script type="module" >
    import { formatDate } from 'https://rawgit.com/cifergit/date-format-helper/master/src/module.js'
</script>
```
Html in IE
```html
<script src="https://rawgit.com/cifergit/date-format-helper/master/index.js"></script>
<script>
   var dateFormat = window['date-format-helper'].dateFormat
</script>
```
### dateFormat Props

| Props        | Options           | Default  | Description |
| ------------- |-------------| -----| -------- |
| t | Date,Number,String |0| Any date that JS can recognize |
| format | String | 'YYYY-MM-DD hh:mm:ss' | YYYY=year<br>MM=month<br>DD=day<br>hh=hours<br>mm=minutes<br> ss=seconds<br>SSS=milliseconds<br><br>you can free combination in any order |
| unit | String |'ms'| if value is 's' mean number is seconds |

#### Notice: 't,format,unit' are optional. Normally the 'Props' is object, but 't' instead of 'Props' is allowed.

## Demo
```javascript
dateFormat()
// 1970-01-01 08:00:00
dateFormat(1601373600000 )
// 2020-09-29 18:00:00
dateFormat('Tue Sep 29 2020 18:00:00 GMT+0800 (China Standard Time)')
// 2020-09-29 18:00:00
dateFormat({t: new Date(), format: 'YYYY-MM-DD hh:mm:ss.SSS'}) // if now is 1601373600000
// 2020-09-29 18:00:00.000
dateFormat({t: '2020-09-29 18:00:00', format: 'hh:mm MM-DD-YYYY'})
// 18:00 09-29-2020
dateFormat({t: 1601373600000, format: 'YYYY-MM-DD'})
// 2020-09-29
dateFormat({t: 1601373600, unit: 's'})
// 2020-09-29 18:00:00
```

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