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