黄子涵

查漏补缺——说说toDateString方法

问题

如题所示

答案

相关源码:

export function getTime(type) {
  if (type === 'start') {
    return new Date().getTime() - 3600 * 1000 * 24 * 90
  } else {
    return new Date(new Date().toDateString())
  }
}

使用Date对象中toDateString判断日期是否当天

将Date对象的日期部分转换为字符串。

posted @ 2022-07-03 18:36  黄子涵  阅读(40)  评论(0编辑  收藏  举报