判断时间是否是当天

function isToday(date) {
  return new Date().toDateString() === date.toDateString();
}
复制代码
function isToday(date) {
  //Code goes here.
    var d = new Date(date.toString().replace(/-/g,"/"));
    var todaysDate = new Date();
    if(d.setHours(0,0,0,0) == todaysDate.setHours(0,0,0,0)){
        return true;
    } else {
        return false;
    }
}
复制代码
function isToday(date) {
  return new Date().toString().substr(0, 15) === date.toString().substr(0, 15);
}
function isToday(date) {
  return date.toString().slice(0, 10) === new Date().toString().slice(0, 10);
}
posted @ 2019-08-21 15:18  阿蒙不萌  阅读(2204)  评论(0编辑  收藏  举报