카타 8급 Is the date today

Jmnote (토론 | 기여)님의 2019년 1월 28일 (월) 16:34 판 (새 문서: ==개요== {{카타 헤더}} {{카타 8급-1}} |} ==JavaScript== 분류: JavaScript <source lang='JavaScript'> function isToday(date) { return new Date().toDateString() == date...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요

카타 8급 C
# 🔗 문제 풀이

틀:카타 8급-1

2 JavaScript

JavaScript
Copy
function isToday(date) {
  return new Date().toDateString() == date.toDateString();
}
JavaScript
Copy
function isToday(date) {
  return new Date().toString().substr(0, 15) == date.toString().substr(0, 15);
}
JavaScript
Copy
function isToday(date) {
  var today = new Date();
  if( date.getDate() != today.getDate() ) return false;
  if( date.getMonth() != today.getMonth() ) return false;
  if( date.getFullYear() != today.getFullYear() ) return false;
  return true;
}