@domoskanonos/date-util
v1.0.4
Published
useful methods for Date class, f.e. convert date object in string and vice versa.
Downloads
2
Readme
date-util
useful methods for Date class, f.e. convert date object in string and vice versa.
|project info|| |:-------------|:-------------| |npm| | |github| | |donation||
convert date object to string
const dateUtil: DateUtil = new DateUtil();
const dateExample = new Date("December 17, 1995 03:24:37");
const dateExampleAsString = dateUtil.formatDate(compareDate, "yyyy-MM-dd");
console.log(dateExampleAsString); // output -> 1995-12-17;
convert string to date object
const dateUtil: DateUtil = new DateUtil();
const dateExample : Date = dateUtil.parseDate("1995-12-17 03:24 37", "yyyy-MM-dd hh:mm ss");
diff dates
const dateUtil: DateUtil = new DateUtil();
dateUtil.diffDays(new Date(2013, 11, 31), new Date(2013, 12, 1)); // output -> 1
replace table for string input
- d -
day
- y,Y -
year
- M -
month
- h,H -
hours
- m -
Minute
- s -
Second
- S -
Milisecond