1

I am trying to use the Date field of JavaScript as below

var dateFrom = new Date(2013,02,03,00,00,00,00); 
var dateTo = new Date(2014,03,01,23,59,59,00);  
alert (dateFrom); 
alert(dateTo);

These are not giving the correct dates.. What am I doing wrong?

1 Answers1

0

Months start from index 0.

You surely expect: 3 February and 1 March
But you got: 3 March and 1 April

Try this:

var dateFrom = new Date(2013,1,3,0,0,0,0); 
var dateTo = new Date(2014,2,1,23,59,59,0);  
alert (dateFrom); 
alert(dateTo);
Mik378
  • 21,881
  • 15
  • 82
  • 180
  • If that is indeed the problem (which it most likely is) then it's a duplicate of http://stackoverflow.com/q/12254333/218196 – Felix Kling Feb 02 '14 at 03:03