"카타 8급 Is the date today"의 두 판 사이의 차이

(새 문서: ==개요== {{카타 헤더}} {{카타 8급-1}} |} ==JavaScript== 분류: JavaScript <source lang='JavaScript'> function isToday(date) { return new Date().toDateString() == date...)
 
1번째 줄: 1번째 줄:
==개요==
==개요==
{{카타 헤더}}
{{카타 헤더}}
{{카타 8급-1}}
{{카타 8급-17}}
|}
|}



2019년 2월 3일 (일) 02:27 판

1 개요

카타 8급 C
# 🔗 문제 풀이

틀:카타 8급-17

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;
}