I have a select menu with options looking something like this…
<option value="2013, 2, 1">01/03/2013</option>
I want to create an array of the dates from this menu but as milliseconds
so I need something like:
myArray = [1368140400000,... etc]
Any ideas how I can get this? I’ve tried this so far but it doesn’t work, returning NaN instead.
var startDates = new Array;
$("select.startdates").find("option").each( function() {
startDates.push(new Date($(this).val()).getTime())
});
2013, 2, 1is no valid date that is recognized byDate.parse. This should work better:However, I think it should be easier to store the milliseconds themselves in the
optionvalue, so that you can easily usenew Date(parseInt(this.value, 10))