# use-moment

> It's simpler to use moment js, support reactjs, nextjs, nodejs, typescripts, use esbuild

Latest version **1.3.2** (published 2023-08-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install use-moment
pnpm add use-moment
yarn add use-moment
bun add use-moment
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.2 |
| Published | 2023-08-12 |
| First published | 2022-06-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 44.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | duongdam |
| Maintainers | duong.dkp |
| Keywords | use moment, moment, moment range, simpler moment js |

## Links

- npm: https://www.npmjs.com/package/use-moment
- Repository: https://github.com/ClassFunc/use-moment
- Homepage: https://github.com/duongdam/use-moment
- Issues: https://github.com/ClassFunc/use-moment/issues
- npm.io page: https://npm.io/package/use-moment

## Dependencies (3)

- [moment](https://npm.io/package/moment.md) ^2.29.4
- [moment-range](https://npm.io/package/moment-range.md) ^4.0.2
- [moment-timezone](https://npm.io/package/moment-timezone.md) ^0.5.43

## Recent versions

- 1.3.2 (latest) — 2023-08-12
- 1.3.1 — 2023-02-24
- 1.3.0 — 2022-11-16
- 1.2.22 — 2022-07-18
- 1.2.21 — 2022-07-15
- 1.2.20 — 2022-07-15
- 1.2.19 — 2022-07-14
- 1.2.18 — 2022-07-14
- 1.2.17 — 2022-07-12
- 1.2.16 — 2022-07-12
- 1.2.15 — 2022-07-12
- 1.2.14 — 2022-07-06
- 1.2.13 — 2022-06-30
- 1.2.12 — 2022-06-30
- 1.2.11 — 2022-06-29
- … 23 more at https://npm.io/package/use-moment/versions

## README

## use-moment

It's simpler to use moment js

## Notice

Same with use-dayjs, you can refer to:
[https://www.npmjs.com/package/use-dayjs](https://www.npmjs.com/package/use-dayjs)

## Support for

```bash
- Typescript
- React js
- Next js
- Node js
```

## Install package

```html
npm i --save use-moment

yarn add use-moment
```

## Use package

```html
Sample import moment range

* mmRanges
1.mmRange
import * as moment from "../index";
import {extendMoment} from 'moment-range';
const mmRange = extendMoment(moment);

let aTime = new Date()
let bTime = new Date("2022-06-30")
2. mmRangeOnly
use: mmRangeOnly(aTime, bTime)
//output: t {start: Moment<2022-06-28T10:35:40+07:00>, end: Moment<2022-06-30T07:00:00+07:00>}
3. mmRangeBy
use: mmRangeBy(aTime, bTime, "days")
//output: { [Symbol(Symbol.iterator)]: [Function (anonymous)] }

4. mmRangeByArray
use: mmRangeByArray(aTime, bTime, "days")
//output: [Moment<2022-06-28T10:38:53+07:00>, Moment<2022-06-29T10:38:53+07:00>]
//This array include moment value

* mmTimezone
1. mmByZone
use: mmFormat(mmByZone(aTime, 'Asia/Tokyo'))
//output: 2022-06-28T12:38:53+09:00
2. mmGuestZone
use: mmGuestZone()
//output: Asia/Saigon

* mmConverts
1.
mmToDate
mmToDate(_now) // output: 2022-06-28T03:14:40.895Z
2.
mmAdd
mmAdd(_now, 1, 'days') // output: Moment<2022-06-29T10:15:42+07:00>
3.
mmSubtract
mmSubtract(_now, 1, 'days') // output: Moment<2022-06-27T10:17:31+07:00>
4.
mmDiff
mmDiff(_now, _now) // output: 0
5.
mmSet
mmSet(_now, {hours: 3, minutes: 30, seconds: 30, milliseconds: 30}) // output: Moment<2022-06-28T03:30:30+07:00>

* mmChecks
1.
mmIsSame
mmIsSame(_now, _now) // output: true
2.
mmIsAfter // output: true/false
3.
mmIsBefore // output: true/false
4.
mmIsSameOrAfter // output: true/false
5.
mmIsSameOrBefore // output: true/false
6.
mmIsSameDate // output: true/false

* mmFormats
1. mmFormat // output: 2022-06-28T10:28:23+07:00
2. mmFormatUTC // output: 2022-06-28T03:28:55Z
3. mmFormatDDD // output: Tue
4. mmFormatMMDD // output: 06/28
5. mmFormatYYYYMMDD // output: 2022-06-28
6. mmFormatDDDD // output: Tuesday
7. mmFormatDDMM // output: 28/06
8. mmFormatYYYY // output: 2022
9. mmFormatYYYYMMDDHHMMSSZ // output: 20220628T033015Z

* mmExtras
1. mmStartOfDay
2. mmStartOfWeeks
3. mmStartOfIsoWeeks
4. mmStartOfMonth
5. mmStartOfMonths
6. mmEndOfDay
7. mmEndOfWeek
8. mmEndOfWeeks
9. mmEndOfIsoWeeks
10. mmEndOfMonth
11. mmEndOfMonths
12. mmIsoWeekDay
13. mmIsoWeeksDays

```

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