dateFunction.js 428 Bytes
Newer Older
YoonDongMin's avatar
0808DM    
YoonDongMin committed
1
export function getDateStr(item) {
Choi Ga Young's avatar
Choi Ga Young committed
2
3
4
5
6
7
    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}`
}