# thor-time

> A simple date time helper toolkit.

Latest version **1.1.1** (published 2020-11-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install thor-time
pnpm add thor-time
yarn add thor-time
bun add thor-time
```

## 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.1 |
| Published | 2020-11-14 |
| First published | 2020-05-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 64.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | thor.qin@outlook.com |
| Maintainers | thor.qin |
| Keywords | data, time |

## Links

- npm: https://www.npmjs.com/package/thor-time
- Repository: https://gitee.com/thor.qin/thor-time
- npm.io page: https://npm.io/package/thor-time

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

- 1.1.1 (latest) — 2020-11-14
- 1.1.0 — 2020-11-01
- 1.0.3 — 2020-06-01
- 1.0.2 — 2020-05-19
- 1.0.1 — 2020-05-14
- 1.0.0 — 2020-05-14

## README

# thor-time

### Description

A JavaScript time helper toolkit.

### Installation

```
npm i thor-time
```

### How to use

1. Import it

```javascript
import time from "thor-time";
```

2. time.now()

```javascript
console.log(time.now()); // get current time equal to new Date()
```

3. time.moment()

```javascript
console.log(time.moment(200000)); // get description string of a time duration: xxx days xxx hours xxx minutes xxx seconds
console.log(time.moment(200000), { maxUnit: "h" }); // biggest unit is hour
console.log(time.moment(200000), { minUnit: "m" }); // smallest unit is minute
// available unit are 'd', 'h', 'm', 's'
```

4. time.distance()

```javascript
console.log(time.distance("2019-1-1", "2020-2-10", "d"));
// available unit are 'd', 'h', 'm', 's', 'ms'
```

5. time.add()

```javascript
console.log(time.add("2019-1-1", 30, "d"));
// available unit are 'd', 'h', 'm', 's', 'ms'
```

6. time.dayOfYear()

```javascript
console.log(time.dayOfYear(new Date()));
```

7. time.daysOfMonth()

```javascript
console.log(time.daysOfMonth(new Date())); // get total days of month
```

8. time.parse()

```javascript
console.log(time.parse('2019-1-12'));
console.log(time.parse('2019-1-12 22:22:00'));
console.log(time.parse('2019-1-12T22:22:00+0800'));
console.log(time.parse('2019-1-12T22:22:00Z'));
console.log(time.parse('1/1/2020'));
console.log(time.parse('Jan 1, 2020'));
......
// if some format cannot be auto detect, you can specify format manually
console.log(time.parse('2019年5月31日 20:08:30', 'yyyy年M月d日 hh:mm:ss'));
```

9. time.format()

```javascript
console.log(time.format(time.now()); // use default format ISO8601 to convert to string
console.log(time.format(time.now(), 'yyyy年MM月dd日'); // use custom format to convert
......
```

That's all

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