# date-time

> Pretty datetime: `2014-01-09 06:46:01`

Latest version **4.0.0** (published 2021-04-20) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2021-04-20 |
| First published | 2014-01-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=12 |
| Dependencies | 1 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 31 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | datetime, date-time, date, time, utc, iso, timezone, zone, timestamp |

## Links

- npm: https://www.npmjs.com/package/date-time
- Repository: https://github.com/sindresorhus/date-time
- Homepage: https://github.com/sindresorhus/date-time#readme
- Issues: https://github.com/sindresorhus/date-time/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/date-time

## Dependencies (1)

- [time-zone](https://npm.io/package/time-zone.md) ^2.0.0

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

- 4.0.0 (latest) — 2021-04-20
- 3.1.0 — 2019-04-02
- 3.0.0 — 2019-03-02
- 2.1.0 — 2017-06-29
- 2.0.0 — 2017-05-20
- 1.1.0 — 2016-07-20
- 1.0.0 — 2014-08-13
- 0.1.1 — 2014-01-09
- 0.1.0 — 2014-01-09

## README

# date-time

> Pretty datetime: `2014-01-09 06:46:01`

## Install

```
$ npm install date-time
```

## Usage

```js
import dateTime from 'date-time';

dateTime();
//=> '2017-05-20 17:07:05'

dateTime({date: new Date(1989, 2, 4, 10)});
//=> '1989-03-04 09:00:00'

dateTime({showTimeZone: true});
//=> '2017-05-20 17:07:05 UTC+7'

dateTime({local: false});
//=> '2017-05-20 10:07:05'

dateTime({local: false, showTimeZone: true});
//=> '2017-05-20 10:07:05 UTC'

dateTime({showMilliseconds: true});
//=> '2017-05-20 17:07:05 6ms'
```

## API

### dateTime(options?)

### options

Type: `object`

#### date

Type: `Date`\
Default: `new Date()`

Custom date.

#### local

Type: `boolean`\
Default: `true`

Show the date in the local time zone.

#### showTimeZone

Type: `boolean`\
Default: `false`

Show the UTC time zone postfix.

#### showMilliseconds

Type: `boolean`\
Default: `false`

Show the milliseconds in the date if any.

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