# amei-date-format

> date format

Latest version **1.1.0** (published 2022-07-09) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2022-07-09 |
| First published | 2022-07-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | wfanxin |
| Maintainers | wfanxin |
| Keywords | amei, format |

## Links

- npm: https://www.npmjs.com/package/amei-date-format
- npm.io page: https://npm.io/package/amei-date-format

## 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

- 1.1.0 (latest) — 2022-07-09
- 1.0.2 — 2022-07-06
- 1.0.1 — 2022-07-05
- 1.0.0 — 2022-07-05

## README

## Time format tool package



### install

yarn add amei-date-format

npm i amei-date-format



### import

import AmeiData from 'amei-date-format'

import {date, time, strtotime} from 'amei-date-format'



### explain

#### Date format
##### date(format = 'Y-m-d H:i:s', timestamp = '')

According to the format, output the formatted date. The format is limited to special characters（year【Y】、month【m】、day【d】、hour【H】、minute【i】、second【s】）

If 【timestamp】 is not transmitted, it is the current timestamp

example:

```javascript
import AmeiData from 'amei-date-format'
console.log(AmeiData.date()) // 2022-07-06 17:35:07
console.log(AmeiData.date('Ymd')) // 20220706
console.log(AmeiData.date('Y-m-d')) // 2022-07-06
```

#### Get current timestamp

##### time()

example:

```javascript
import AmeiData from 'amei-date-format'
console.log(AmeiData.time()) // 1657100107
```

#### Date to timestamp
##### strtotime(time = '', now = '')

【time】 is a special string with (hours, hours, day, days, week, weeks, month, months, year, years), or is a date

If 【now】 is not transmitted, it is the current timestamp

```javascript
import AmeiData from 'amei-date-format'
console.log(AmeiData.strtotime()) // 1657100107
console.log(AmeiData.strtotime('2022-02-18')) // 1645113600
console.log(AmeiData.strtotime('+1 day', AmeiData.strtotime('2022-02-18'))) // 1645200000
```



### Complex examples：

```javascript
import {date, time, strtotime} from 'amei-date-format'
console.log(date('Y-m-d H:i:s', strtotime('+2 years'))) // 2024-07-06 17:35:07
console.log(date('Y-m-d H:i:s', strtotime('+3 hours +2 days +1 week'))) // 2022-07-15 20:35:07
console.log(date('Y-m-d H:i:s', strtotime('-1 month', strtotime('2022-03-31')))) // 2022-03-03 00:00:00
console.log(date('Y-m-d H:i:s', strtotime('+1 month', strtotime('2022-03-31')))) // 2022-05-01 00:00:00
console.log(date('Y-m-d H:i:s', strtotime('+10 month', strtotime('2022-03-31')))) // 2023-01-31 00:00:00
```

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