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
325 B
16 lines
325 B
/**
|
|
* Get a `YYYY-MM-DD` string.
|
|
*
|
|
* @param {Date} date
|
|
*/
|
|
export default function dateStr(date) {
|
|
function pad(n) {
|
|
return n < 10 ? "0" + n : n.toString();
|
|
}
|
|
|
|
if (!(date instanceof Date)) {
|
|
date = new Date(date);
|
|
}
|
|
|
|
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
|
}
|