I have the following snippet of JavaScript code I use for rendering a date range from the current month to the same month last year:
var today = new Date();
var endDate = new Date(today.getFullYear(), today.getMonth(), 1);
var startDate = new Date(endDate.getYear() - 1, endDate.getMonth() - 1, 1);
In IE 8 it gives me the correct date range:
Fri Jun 1 00:00:00 MST 2012 - Mon Jul 1 00:00:00 MST 2013
When I run the same code in Chrome, I get the following date range:
Wed Jun 01 0112 00:00:00 MST - Mon Jul 01 2013 00:00:00 MST
The year for the start date is 0112. What do I need to do in order to get the correct date range in IE and Chrome?