dateFunction.js 380 Bytes
Newer Older
Soo Hyun Kim's avatar
Soo Hyun Kim committed
1
2
3
4
5
6
7
export function getDateStr (item) {
    let date = ''
    if (item){
        date = new Date(item)
    } else {
        date = new Date()
    }
8
    const tempY = date.getFullYear();
9
    let tempM = date.getMonth()+1;
10
11
12
13
14
    tempM = tempM > 9 ? tempM : "0" + tempM;
    let tempD = date.getDate();
    tempD = tempD > 9 ? tempD : "0" + tempD;
    return `${tempY}-${tempM}-${tempD}`
}