CI / CD | Status |
---|---|
NPM | |
Semaphore CI | |
Circle CI | |
Coverall | |
SonarCloud |
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
const newDate = fromIsoToHuman("2024-01-31T15:27:42.427438", "DD/MM/YYYY");
console.log(newDate); // It prints 31/01/2024
Input | Output |
---|---|
"20220323" | 23/03/2022 |
"2022-03-23" | 23/03/2022 |
"2022-03-09T12:31:16.699904" | 09/03/2022 |
npm install @sineverba/date-convert
// 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
npm run test
for simple test
npm run coverage
for coverage