본문 바로가기
javaScript/JS Tutorial

[javsScript] 날짜 비교 하기

by mooyou 2022. 11. 23.
728x90
300x250

오늘 날짜를 2100년 1월 1일과 비교하기

let text = "";
const today = new Date();
const someday = new Date();
someday.setFullYear(2100, 0, 14);

if (someday > today) {
  text = "Today is before January 14, 2100.";
} else {
  text = "Today is after January 14, 2100.";
}//Today is before January 14, 2100.

 

참조 : https://www.w3schools.com/js/js_date_methods_set.asp

728x90
반응형

댓글