garfield11
IS-IT--Management
Hi all,
I have some problem with dates so can anyone please help.
Below r codes to convert eg. 15/2/02 --> 15th Feb 2002:
function convDate(QDate)
{
var dayNum=new Array("1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th","10th", "11th", "12th", "13th", "14th", "15th", "16th", "17th", "18th", "19th", "20th", "21st", "22nd", "23rd", "24th", "25th", "26th", "27th", "28th", "29th", "30th","31st"
var monName=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
var strMainString= QDate.value; //date typed in 1st textbox
var year= strMainString.substring(6,10); //last four
var month= strMainString.substring(3,5); //middle two
var day= strMainString.substring(0,2); //first two
var test = new Date(year, month, day);
output=day+" " +monName[test.getMonth()-1]+ " " +year;
QDate.value=output;
}
But now e problem is:
when I entered a date - day beyond 10 (eg. 10th --> 31th) n month beyond 10 (eg. 10 --> 12 that's Oct --> Dec) can convert
whereas
when i entered a date - day before 10 (eg. 1st --> 9th) n month before 10 (eg. 1 --> 9 that's Jan --> Sep) got error.. undefined undefined
BUT
if i type 01/01/02 (put a "0" in front)- can convert
so can anybody tell me what's wrong?
Thanks!
Love_Garfield
I have some problem with dates so can anyone please help.
Below r codes to convert eg. 15/2/02 --> 15th Feb 2002:
function convDate(QDate)
{
var dayNum=new Array("1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th","10th", "11th", "12th", "13th", "14th", "15th", "16th", "17th", "18th", "19th", "20th", "21st", "22nd", "23rd", "24th", "25th", "26th", "27th", "28th", "29th", "30th","31st"
var monName=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
var strMainString= QDate.value; //date typed in 1st textbox
var year= strMainString.substring(6,10); //last four
var month= strMainString.substring(3,5); //middle two
var day= strMainString.substring(0,2); //first two
var test = new Date(year, month, day);
output=day+" " +monName[test.getMonth()-1]+ " " +year;
QDate.value=output;
}
But now e problem is:
when I entered a date - day beyond 10 (eg. 10th --> 31th) n month beyond 10 (eg. 10 --> 12 that's Oct --> Dec) can convert
whereas
when i entered a date - day before 10 (eg. 1st --> 9th) n month before 10 (eg. 1 --> 9 that's Jan --> Sep) got error.. undefined undefined
BUT
if i type 01/01/02 (put a "0" in front)- can convert
so can anybody tell me what's wrong?
Thanks!
Love_Garfield