...

View Full Version : Date and Month Switch Problem



tunayx
08-19-2008, 02:47 PM
I tried to switch date and month in this script to show dd-mm but my modification didn't worked, day is okay but month becomes 71 instead of 7+1=8 Help needed.



Original Script:

myDate = new Date(document.lastModified);
displayDate = myDate.getMonth()+1 + "-" + myDate.getDate()
document.writeln("Son Güncelleme: " + displayDate + "-2008" )


My Mod that not worked:

displayDate = myDate.getDate() + "-" + myDate.getMonth()+1

m_sundar
08-19-2008, 03:38 PM
Hi tunayx,

The script wat ever u have posted works fine. there is no problem with it.

But still if u find problems try using parseInt

displayDate = parseInt(myDate.getMonth())+1 + "-" + myDate.getDate()

dumpfi
08-19-2008, 03:39 PM
Use this:
displayDate = myDate.getDate() + "-" + (myDate.getMonth()+1)The parantheses allow the + to be treated as addition instead of concatenation.

dumpfi

tunayx
08-19-2008, 03:44 PM
Thanks dumpfi, worked fine.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum