【发布时间】:2020-09-17 15:52:30
【问题描述】:
我正在尝试检查日历 (fullcalendar) 中的日期,本质上我只是希望它无法选择过去的日期:
dateClick: function(info) {
var today = Date.now();
var check = new Date(info.dateStr)
if(check < today)
{
alert('You cannot request dates in the past');
return;
}
else
{
alert('this is the future');
}
},
我得到了一些奇怪的结果,它似乎可以计算过去的罚款,但也可以将当前日期计算为过去 AS 和明天。后天计算为未来。不知道发生了什么。
info.dateStr 给出格式 YYYY-mm-dd。
【问题讨论】:
-
也许您今天需要转换为 yymmdd。也 gmt 可能会干扰