here I need to know the day based on this date. But the string is not gettin converted to date and hence the result that i get is NaN. Can someome please help me on this issue? I need the logic in javascript
No timezone is indicated, so you may intend to use the user’s local time,
which will make it a different absolute date depending on where the user is at the time.
It could also mean november 7 or july 11, depending on the local formatting.
If you want to return july 11,2010, local time,
split the string into an array of numbers
and use the Date constructor- new Date (yyyy, mm-1, dd).
Months are zero indexed.
var d, nDate, sDate= '11-07-2010';
d=sDate.split('-');
d[0]= parseInt(d[0],10);
d[1]= parseInt(d[1],10)-1;
d[2]= parseInt(d[2],10);
var nDate = new Date(d[2],d[1],d[0]);
//test
alert(nDate);
/* returned value: (local Date)
Sun Jul 11 2010 00:00:00 GMT-0400 (Eastern Daylight Time)
*/
alert(nDate.getDay())
/* returned value: (Number)
0