daterJS - Date formatting made easy
daterJS
date formatting made easy !
Install:
npm install daterjs
Usage:
Create a Node or JS File and copy the all the code below
/index.js
Import module:
const formats = require('daterjs');
//dates
var date1 = '2019:29:12';
var date2 = '2019:12:29';
var date3 = '29:12:2019';
var date4 = '12:29:2020';
var ukDate = '12/29/2020';
Send to client/UI:
console.log(formats.getTodaysDate());
prints: 1/20/2020, 12:31:25 AM
console.log('\x1b[36m%s\x1b[0m',formats.getTodaysDateUK(ukDate));
prints: 29/12/2020
console.log(formats.formatUK(date1));
prints: 12/29/2019
console.log(formats.formatUS(date1));
prints: 2019/29/12
console.log(formats.formatDayDateYearTimeFormatter1(date1));
prints: Tuesday December 2020
console.log(formats.formatDayDateYearTimeFormatter2(date2));
prints: Tuesday December 2020`
console.log(formats.formatDayDateYearTimeFormatter2(date2));
prints: 23 January 2020`
console.log(formats.formatDayDateYearTimeFormatter2(date2));
prints: December 22 2020`
Running:
If you have nodejs installed simply run by calling this file: node index.js this will print the dates in your node console.
If you want to make use of the helper in a website or web app, simple copy all of the code from node_modules/daterjs and paste into a JS and call it daterjs.js then import it into your HTML file.
Then test it call by calling the function like so:
<script type="javascript"> console.log(getTodaysDate()) </script>
This example uses pure OOP JS but you can obviously attache to user events too like mouse clicks or buttons.
Like what I am doing? If so and are using my modules in your projects then please consider sponsoring me on Patreon: here
NEW RELEASES:
V2.0.0
Major function change - change any given month number into month word i.e. 9/29/01 or 29/9/20 to September.
Example call:
var date1 = '2019:9:18';
var date1a = '19:7:2019';
var date1b = '3:19:18';
console.log(formats.dateToMonthChanger(date1b));