# dtil

> simple date util

Latest version **1.1.0** (published 2021-01-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install dtil
pnpm add dtil
yarn add dtil
bun add dtil
```

## 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 | 2021-01-08 |
| First published | 2021-01-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 18 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Choi jinwoo |
| Maintainers | choi-jinwoo |
| Keywords | date, date format, date util, date compare |

## Links

- npm: https://www.npmjs.com/package/dtil
- Repository: https://github.com/Choi-Jinwoo/Dtil
- Homepage: https://github.com/Choi-Jinwoo/Dtil#readme
- Issues: https://github.com/Choi-Jinwoo/Dtil/issues
- npm.io page: https://npm.io/package/dtil

## 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.0 (latest) — 2021-01-08
- 1.0.11 — 2021-01-07
- 1.0.10 — 2021-01-07
- 1.0.9 — 2021-01-07
- 1.0.8 — 2021-01-07
- 1.0.7 — 2021-01-07
- 1.0.6 — 2021-01-07
- 1.0.5 — 2021-01-06
- 1.0.4 — 2021-01-06
- 1.0.3 — 2021-01-06
- 1.0.2 — 2021-01-06
- 1.0.1 — 2021-01-06
- 1.0.0 — 2021-01-06

## README

# Dtil

npm package simple date util

![](https://img.shields.io/npm/v/dtil.svg)
![](https://img.shields.io/npm/dm/dtil.svg)

# Installing

Using npm
```
$ npm install dtil
```

Using yarn
```
$ yarn add dtil
```


# Example

## Import

You can import function. Imported function return `Dtil` class object.

### ES5
```javascript
const dtil = require('dtil');

const aDtil = dtil('2020-08-28'); // Date string
const bDtil = dtil(new Date('2020-08-28')); // Date object
const cDtil = dtil(new Date('2020-08-28').getTime()); // number
```

### ES6
```javascript
import dtil from 'dtil';

const aDtil = dtil('2020-08-28'); // Date string
const bDtil = dtil(new Date('2020-08-28')); // Date object
const cDtil = dtil(new Date('2020-08-28').getTime()); // number
```

## Format

|char|description|
|---|---|
|yyyy / YYYY|year|
|MM|two-digit month |
|M|month|
|dd / DD|two-digit date|
|d / D|date|
|HH|two-digit hour(24)|
|H|hour(24)|
|hh|two-digit hour(12)|
|h|hour(12)|
|mm|two-digit minute|
|m|minute|
|SS / ss|two-digit second|
|S / s|second|

### Usage
```javascript
const dtil = require('dtil');

const date = dtil('2020-08-28');
console.log(date.format('yyyy/MM/dd')); // result: '2020/08/28'
```

## Method

|method|return type|description|
|---|---|---|
|format|string|format date string|
|isSameDate|boolean|check date and param is same date|
|isAfter|boolean|check date is after param|
|isAfterNow|boolean|check date is after now|
|isBefore|boolean|check date is before param|
|isBeforeNow|boolean|check date is before now|

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