Reputation: 175
so I just want to find wether a date is before today or a day in future. So basiclly I have this construction:
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);
}
}
}
Than I call it like this:
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();
So tried to figure out, what javascript creates:
start:1364036625000
end: 1364382225000
today: 1361796935000
I also parsed it back into the standard format:
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
So I have no idea, how to fix it or how it could work...
Upvotes: 0
Views: 58
Reputation: 382092
Your problem isn't explicitly stated but you seem to forget (or ignore) that months are zero-indexed in javascript. February is 1
.
Upvotes: 1