- new Date() 생성자는 날짜를 생성할때 자동으로 현지 시간으로 변환한다.
- new Date()의 month parameter는 0 - 11 까지의 값을 가지며, 0은 1월이다.
function solution(month, day){
var date = new Date(2022, month, day+98);
let getMonth = date.getMonth();
let getDay = date.getDate();
return getMonth+'월'+getDay+'일';
}
console.log(solution(6,22))
function solution(month, day){
var date = new Date(2022, month, day);
console.log(date)
let getMonth = date.getMonth();
let getDay = date.getDate();
return getMonth+'월'+getDay+'일';
}
console.log(solution(6,22))
function solution(month, day){
var date = new Date(2022, month-1, day+98);
console.log(date)
let getMonth = date.getMonth()+1;
let getDay = date.getDate();
return getMonth+'월'+getDay+'일';
}
console.log(solution(6,22))
- Date() 생성자, UTC 시간은 위의 상황뿐 아니라, 현지시간의 오류도 있기에 잘 뜯어봐야할것같다.