所以我只是想知道日期是在今天之前还是在将来的某一天。基本上我有这种结构:
function data(startdate, enddate)
{
var that = this;
start = startdate;
end = enddate;
var today = new Date();
today = today.getTime();
today = Date.parse(today);
this.status = false; // True = Server is in maintenance
this.init = function()
{
isDone();
}
function isDone(){
if( Date.parse(start) < today && today < Date.parse(end))
{
that.status = true;
console.log(that.status);
}else
{
that.status = false;
console.log(that.status);
}
}
}
我称之为:
var x1 = new Date(2013,2,23,12,3,45);
var x2 = new Date(2013,2,27,12,3,45);
var foobar = new data(x1,x2);
foobar.init();
所以试图找出javascript创建的内容:
start:1364036625000
end: 1364382225000
today: 1361796935000
我还将其解析为标准格式:
start:Sat Mar 23 2013 12:03:45 GMT+0100
end:Wed Mar 27 2013 12:03:45 GMT+0100
today:Mon Feb 25 2013 13:54:56 GMT+0100
所以我不知道,如何修复它或它是如何工作的......
答案 0 :(得分:1)
您的问题没有明确说明,但您似乎忘记(或忽略)javascript中的零索引。二月是1
。