Javascript Date problem. Pls help

I am having browser issue for javascript

Check this code below:

var variable = newDate+monthYear;
(consider the variable value to be ‘01-07-2010’)

//Split this variable
var sDate = variable.split(‘-’);

//make it in format ‘2010-07-01’
sDate = sDate[2] + ‘-’+sDate[1]+‘-’+sDate[0];

//create date object and pass the value
var date = new Date(sDate)

//Display the day for that date

In Firefox i get the day correctly. But in IE 8 it is coming as NaN when i give this alert. Can someone help me get the correct code so that i get the correct day in IE also. Pls its urgent

Your code is trying to use ‘2010-07-01’ for the dateStamp.

Even though Firefox is more flexible in what the web browser will accept, the actual specifications on Mozilla’s javascript reference page for Date object says that:

The string should be in a format recognized by the parse method ([url=“”]IETF-compliant RFC 1123 timestamps).

You don’t have to use the dateString syntax though. These are the acceptable syntaxes for Date

[indent]new Date()
new Date(milliseconds)
new Date(dateString)
new Date(year, month, date [, hour, minute, second, millisecond ])

Given that you already have the year month and date, I suggest that you use new Date(year, month, date) instead of the dateString.

var date = new Date(sDate[2], sDate[1], sDate[0]);