I currently have a date picker on the client side. Once a date is selected the date in milliseconds is sent to my node app. the problem is i am getting Invalid Date for new Date(milliseconds)
the milliseconds sent look like this ( 1347433200000 ) my code is as fallows
app.get('/dashboard/date/:date', function(req, res){
console.log(new Date(req.params.date));
var start = new Date(req.params.date);
var end = new Date(req.params.date).add({hours:23, minutes:59, seconds: 59, milliseconds: 999});
console.log(start);
console.log(end);
Appointments.find({'scheduled' : {"$gte": start, "$lt": end}}, function(err, list){
res.render('templates/list',{ layout: false, appointments: list });
});
});
req.params.date
is a string so you need to convert it to a number before passing it to the Date
constructor. Try this instead:
var start = new Date(Number(req.params.date));