# @sineverba/date-convert

> Convert a date from / to ISO format YYYYMMDD to human readable format (DD/MM/YYYY)

Latest version **2.3.0** (published 2024-02-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @sineverba/date-convert
pnpm add @sineverba/date-convert
yarn add @sineverba/date-convert
bun add @sineverba/date-convert
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.3.0 |
| Published | 2024-02-29 |
| First published | 2020-09-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12 |
| Dependencies | 2 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | alessandro.arici@gmail.com |
| Maintainers | sineverba |
| Keywords | npm, package, date, format |

## Links

- npm: https://www.npmjs.com/package/@sineverba/date-convert
- Repository: https://github.com/sineverba/npm-pkg-date-convert
- Homepage: https://github.com/sineverba/npm-pkg-date-convert#readme
- Issues: https://github.com/sineverba/npm-pkg-date-convert/issues
- npm.io page: https://npm.io/package/@sineverba/date-convert

## Dependencies (2)

- [npm](https://npm.io/package/npm.md) ^10.5.0
- [moment](https://npm.io/package/moment.md) ^2.30.1

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

- 2.3.0 (latest) — 2024-02-29
- 2.2.0 — 2023-12-22
- 2.1.0 — 2023-07-26
- 2.0.0 — 2023-03-13
- 1.4.0 — 2023-01-15
- 1.3.0 — 2022-05-11
- 1.2.0 — 2022-05-10
- 1.1.0 — 2022-01-29
- 1.0.0 — 2021-02-25
- 0.2.0 — 2021-02-17
- 0.1.0 — 2020-09-08

## README

Date Convert
============

| CI / CD | Status |
| ------- | ------ |
| NPM | [![npm version](https://badge.fury.io/js/%40sineverba%2Fdate-convert.svg)](https://badge.fury.io/js/%40sineverba%2Fdate-convert) |
| Semaphore CI | [![Build Status](https://sineverba.semaphoreci.com/badges/npm-pkg-date-convert/branches/master.svg)](https://sineverba.semaphoreci.com/projects/npm-pkg-date-convert) |
| Circle CI | [![CircleCI](https://circleci.com/gh/sineverba/npm-pkg-date-convert.svg?style=svg)](https://circleci.com/gh/sineverba/npm-pkg-date-convert) |
| Coverall | [![Coverage Status](https://coveralls.io/repos/github/sineverba/npm-pkg-date-convert/badge.svg?branch=master)](https://coveralls.io/github/sineverba/npm-pkg-date-convert?branch=master) |
| SonarCloud | [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=npm-pkg-date-convert&metric=alert_status)](https://sonarcloud.io/dashboard?id=npm-pkg-date-convert) |


`date-convert` converts a ISO format YYYYMMDD string "19820405" to "05/04/1982" (where 05 is day and 04 is April). Use `"/"` as separator in output.

It works also with a date with other format. Simply, call the method `fromIsoToHuman`.

For example

```js
const newDate = fromIsoToHuman("2024-01-31T15:27:42.427438", "DD/MM/YYYY");
console.log(newDate); // It prints 31/01/2024
```

### Accepted INPUT

| Input | Output |
| ----- | -------|
| "20220323" | 23/03/2022 |
| "2022-03-23" | 23/03/2022 |
| "2022-03-09T12:31:16.699904" | 09/03/2022 |


## Installation
`npm install @sineverba/date-convert`

## Usage

```js
// Import module
import { fromHumanToIso, fromIsoToHuman } from "@sineverba/date-convert";
// Or
// var {fromIsoToHuman, fromHumanToIso} = require('@sineverba/date-convert');

const humanDate = fromIsoToHuman("20200102");
console.log(humanDate); // returns 02/01/2020

const humanDateWithFormat = fromIsoToHuman("20200102", "YYYY-MM-DD");
console.log(humanDateWithFormat); // returns 2020-01-02

const isoDate = fromHumanToIso("02/01/2020");
console.log(isoDate); // returns 20200102

const isoDateWithFormat = fromHumanToIso("2020-01-02", "YYYY-MM-DD");
console.log(isoDateWithFormat); // returns 20200102
```

## Tests

`npm run test` for simple test

`npm run coverage` for coverage

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