function getYYYYMMDDToString(dateStr){
const date = new Date(dateStr);
const seconds = date.getSeconds();
const minuites = date.getMinutes();
const hh = date.getHours();
const dd = date.getDate();
const mm = date.getMonth()+1;
const yyyy = date.getFullYear();
let ddStr = {
"seconds" : (seconds < 10) ? "0" + seconds.toString() : seconds.toString(),
"minuites" : (minuites < 10) ? "0" + minuites.toString() : minuites.toString(),
"hh" : (hh < 10) ? "0" + hh.toString() : hh.toString(),
"mer" : (hh < 12) ? "오전" : "오후",
"dd" : (dd < 10) ? "0" + dd.toString() : dd.toString(),
"mm" : (mm < 10) ? "0" + mm.toString() : mm.toString(),
"yyyy" : yyyy.toString()
}
// const s1 = `${ddStr.yyyy}년 ${ddStr.mm}월 ${ddStr.dd}일 ${ddStr.mer} ${ddStr.hh}:${ddStr.minuites}:${ddStr.seconds}`;
const s1 = `${ddStr.yyyy}년 ${ddStr.mm}월 ${ddStr.dd}일`;
return s1;
}
위의 코드를 입맛에 맞게 수정해서 사용하면 되겠다.