카타 8급 Is the date today

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