Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2007
    Posts
    60
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Date and Month Switch Problem

    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
    Last edited by tunayx; 08-19-2008 at 03:18 PM.

  • #2
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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()

  • #3
    Regular Coder
    Join Date
    Jun 2004
    Posts
    565
    Thanks
    0
    Thanked 18 Times in 18 Posts
    Use this:
    Code:
    displayDate = myDate.getDate() + "-" + (myDate.getMonth()+1)
    The parantheses allow the + to be treated as addition instead of concatenation.

    dumpfi
    "Failure is not an option. It comes bundled with the software."
    ....../)/)..(\__/).(\(\................../)_/)......
    .....(-.-).(='.'=).(-.-)................(o.O)...../<)
    ....(.).(.)("}_("}(.)(.)...............(.)_(.))Ż/.
    ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
    Little did the bunnies suspect that one of them was a psychotic mass murderer with a 6 ft. axe.

  • #4
    New Coder
    Join Date
    Apr 2007
    Posts
    60
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks dumpfi, worked fine.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •