Chronos is a light weight time and date string manipulation function.
npm i @hasala2002/chronos --save
Then...
const chronos = require('@hasala2002/chronos');
let date = chronos.format('ddd-Mmm-yyy')
console.log(date)
Code | Description | Example |
---|---|---|
yyyy | Full Year | 2020 |
yy | Year (Last two digits) | 20 |
ddd | Date with suffix | 1st |
dddf | Date with suffix | 1st of |
dd | Date w/o suffix | 1 |
Www | Weekday with first letter capitalized | Monday |
WWW | Weekday fully capitalized | MONDAY |
www | Weekday fully simplified | monday |
Mmm | Month with first letter capitalized | January |
MMM | Month fully capitalized | JANUARY |
mmm | Month fully simplified | january |
Ww | Weekday short with first letter capitalized | Mon |
WW | Weekday short fully capitalized | MON |
ww | Weekday short fully simplified | mon |
Mm | Month short with first letter capitalized | Jan |
MM | Month short fully capitalized | JAN |
mm | Month short fully simplified | jan |
xxx, | Any text with comma behind it (Doesnt work with dddf) | Monday, |
Example
chronos.format('ddd-Www,-Mmm-yyyy');
//13th Thursday, June 2002
Code | Description |
---|---|
hh | Hours |
mm | Minutes |
ss | Seconds |
CC | Captilized 12 Hour Clock |
cc | Sinplified 12 Hour Clock |
CC, | Captilized 12 Hour Clock with comma |
cc, | Simplified 12 Hour Clock with comma |
Examples
chronos.format('hh:mm:ss'); //16:50:32
chronos.format('hh:mm:ss:CC'); //4:50:32 AM
chronos.format('hh:mm:ss:cc'); //4:50:32 am
chronos.format('hh:mm'); //16:50:32
chronos.format('hh:mm:CC'); //4:50 AM
chronos.format('hh:mm:cc,'); //4:50 am,
Preset | Format |
---|---|
dPrimary | 13th of June 2020, Wednesday |
dSecondary | 13th, June 2020 |
tPrimary | 4.32 pm |
tSecondary | 4.32.59 pm |
- time functions and calculation