You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
381 B
16 lines
381 B
5 years ago
|
|
||
|
const formatToYMD = function (date = null, split = "-" ) {
|
||
|
if (!date) {
|
||
|
date = new Date();
|
||
|
}
|
||
|
let month = `${date.getMonth() + 1}`;
|
||
|
let day = `${date.getDate()}`;
|
||
|
const year = date.getFullYear();
|
||
|
|
||
|
if (month.length < 2) month = `0${month}`;
|
||
|
if (day.length < 2) day = `0${day}`;
|
||
|
|
||
|
return [year, month, day].join(split);
|
||
|
}
|
||
|
|
||
|
export {formatToYMD};
|