Date with Javascript Undefined
Hi! I have a portion of my app that maps the date from the database. I have code to parse it so it only shows the Date and the Month.
When I run the test app in a browser, it works fine. However, when I test it on a mobile device (both in the browser, and as an IPA file), it shows "undefined NaN"
Here's the mapping:
Here's the code:
precode
var startTime = new Date(value);
startTimeMonth = startTime.getMonth();
//Get month
var month=new Array();
month[0]="January"
month[1]="February"
month[2]="March"
month[3]="April"
month[4]="May"
month[5]="June"
month[6]="July"
month[7]="August"
month[8]="September"
month[9]="October"
month[10]="November"
month[11]="December"
var startTimeMonthName = month[startTimeMonth];
//Get date and add suffix
startTimeDate = startTime.getDate();
var j = startTimeDate % 10;
switch(j)
{
case (j == 1 && startTimeDate != 11):
startTimeDateOrd = startTimeDate + "st"
break;
case (j == 2 && startTimeDate != 12):
startTimeDateOrd = startTimeDate + "nd"
break;
case (j == 3 && startTimeDate != 13):
startTimeDateOrd = startTimeDate + "rd"
break;
default:
startTimeDateOrd = startTimeDate + "th"
}
//And return it
//alert(startTimeMonthName + " " + startTimeDateOrd);
return startTimeMonthName + " " + startTimeDateOrd;
/code/pre
Any thoughts?