dateformat is a simple library that formats dates to something more understandable using the object Intl.RelativeTimeFormat. the module requires two parameters, the date and a language, by default the language is set to 'en', the language format supported is .ISO 639-1 code.
// import the module using
const { dateformat } = require('dateformat-mm');
// or
import { dateformat } from 'dateformat-mm';
// use
const dateFormat = dateformat('2020-11-12', 'en');
console.log(dateFormat)
>> 195 days ago
// returns from the current date, the days that have passed in the English language
// or you can also use
const dateFormatEs = dateformat('2021-05-26T01:00:36.876Z', 'es');
console.log(dateFormatEs)
>> hace 16 horas
This project is under license from MIT. For more details, see the LICENSE file.
Made with ❤️ by ManuelMaciel