function getToday() {
    var date = new Date();
    var year = date.getFullYear();
    var month = ("0" + (1 + date.getMonth())).slice(-2);
    var day = ("0" + date.getDate()).slice(-2);
    return year + month + day;
}

20221207

 

function formatDate(start, end, index) {
    if (index == 1) {
        return getToday().slice(start, end) + '년 '
    }
    if (index == 2) {
        return getToday().slice(start, end) + '월 '
    }
    if (index == 3) {
        return getToday().slice(start, end) + '일'
    }
}

2022년12월07일

+ Recent posts