I'm having trouble getting a date string (like "17/08/2012") before a date so that it can be used to compare another date.
I would like to introduce the date 08/17/2012 00:00:00 GMT on 08/17/2012 so that it can be used correctly for comparison. I thought this would be the easiest part of what I'm trying to do, but apparently not. See My current code below.
function dateToString(dateString) { var dateArray = dateString.split("/"); var year = dateArray[2]; var month = dateArray[1]; var day = dateArray[0]; var date = new Date(year, month - 1, day); return date; }
This code is currently producing "Fri Aug 17 16:00:00 PDT 2012," and I have absolutely no idea why it speaks at 16:00. I have tried many different ways to do this in the last hour and still cannot figure out what is right. Any ideas how I can get it to convert correctly?
As always, any help is greatly appreciated.
source share