我正在尝试使用大于运算符来比较两个java脚本日期,但它不起作用,我发布了我的代码,
select : function(date, jsEvent, allDay) {
$('#clickedDateHolder').val(date.format());
var check = date.format();
var date = new Date();
var day = date.getDate();
var month = date.getMonth();
var year = date.getFullYear();
var currentDate = year +'-'+month+'-'+day;
// show modal dialog
alert('check :'+check +'currentDate :'+currentDate)
if(check < currentDate)
{
bootbox.alert("Past Dates")
}else if(check > currentDate){
input.push(date.format());
$('#selectedDate').val(input);
$('#event-modal').modal('show');
}
date.format();给我选择的日期,我使用
格式化当前日期 var day = date.getDate();
var month = date.getMonth();
var year = date.getFullYear();
var currentDate = year +'-'+month+'-'+day;
但是当我使用大于运算符时它不起作用。生成的两种日期格式是
check :2015-10-27 currentDate :2015-9-29
如何解决这个问题?请帮忙
答案 0 :(得分:-1)
你可以用毫秒来得到时间
check > new Date() // currentDate = new Date(), your string breaks it.