# @baiwusanyu/utils-date

> ## Function

Latest version **1.1.2** (published 2024-12-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @baiwusanyu/utils-date
pnpm add @baiwusanyu/utils-date
yarn add @baiwusanyu/utils-date
bun add @baiwusanyu/utils-date
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2024-12-12 |
| First published | 2023-05-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 62.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | baiwusanyu-c |
| Maintainers | baiwusanyu |
| Keywords | typescript, javascript, utils, vue, vue3, vite, react |

## Links

- npm: https://www.npmjs.com/package/@baiwusanyu/utils-date
- Repository: https://github.com/baiwusanyu-c/bwsy-utils
- Homepage: https://github.com/baiwusanyu-c
- Issues: https://github.com/baiwusanyu-c/bwsy-utils/issues
- npm.io page: https://npm.io/package/@baiwusanyu/utils-date

## Dependencies (2)

- [dayjs](https://npm.io/package/dayjs.md) ^1.11.13
- [ansi-colors](https://npm.io/package/ansi-colors.md) ^4.1.3

## 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.2 (latest) — 2024-12-12
- 1.1.1 — 2024-12-12
- 1.1.0 — 2024-12-12
- 1.0.18 — 2023-12-28
- 1.0.17 — 2023-12-28
- 1.0.16 — 2023-09-02
- 1.0.15 — 2023-08-15
- 1.0.14 — 2023-07-08
- 1.0.13 — 2023-05-25
- 1.0.12 — 2023-05-10
- 1.0.11 — 2023-05-08

## README

# @baiwusanyu/utils-date

## Function

### setZeroDate

补0

| 参数     | 参数类型     | 默认值     | 说明        |
|--------|----------|---------|-----------|
| num | `number` | `-`     | 需要补 0 的数字 |

| 返回值 | 返回类型     | 说明     |
|-----|----------|--------|
| res | `string` | 补 0 结果 |

### getLastDay

获取某个月最后一天

| 参数     | 参数类型      | 默认值                        | 说明                                       |
|--------|-----------|----------------------------|------------------------------------------|
| month | `number`  | `-`                        | 月份                                       |
| year | `number`  | `new Date().getFullYear()` | 年份                                       |
| isFull | `boolean` | `false`                 | 是否显示全日期，true 则返回 'YYYY-MM-DD',反之只返回一个数字  |

| 返回值 | 返回类型              | 说明     |
|-----|-------------------|--------|
| res | `string \ number` | 最后一天日期 |

### formatDate

给定一个时间（2023-04-27T07:32:39.000+00:00），返回指定格式日期字符串

| 参数     | 参数类型     | 默认值                    | 说明 |
|--------|----------|------------------------|----|
| time | `string` | `-`                    | 时间 |
| format | `string` | `YYYY-MM-DD HH:mm:ss`  | 格式 |

| 返回值 | 返回类型           | 说明   |
|-----|----------------|------|
| res | `string` | 格式结果 |

### relativeTime

给定两个个时间（2023-04-27T07:32:39.000+00:00），返回相对时间

| 参数        | 参数类型                  | 默认值      | 说明          |
|-----------|-----------------------|----------|--------------------|
| rTime     | `string`              | `-`      | 待比较时间              |
| cTime     | `string`              | `-`      | 待比较时间              |
| isBefore  | `boolean`             | `true`   | 返回 `xxx前` 或 `xxx后` |
| unit      | `unitOfTime.StartOf`  | `hour`   | 单位                 |
| lang      | `string`              | `zh-cn`  | 国际化                |

| 返回值 | 返回类型           | 说明     |
|-----|----------------|--------|
| res | `string` | 相对时间结果 |

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