date format conversion

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RajivNair
    New Member
    • Apr 2007
    • 1

    date format conversion

    how to convert dd/mmm/yyyy to dd/mm/yyyy using java script
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Use the Date() object. Set the day, month and year using the set*** methods. To set the month, use an array with the named months and the index month that matches will be the numbered month.

    Comment

    • praveen1983
      New Member
      • Jan 2008
      • 17

      #3
      Originally posted by RajivNair
      how to convert dd/mmm/yyyy to dd/mm/yyyy using java script
      [CODE=javascript]var today=new Date();
      var t=today.toStrin g().split('U',2 );
      var month=t[0].split(' ',4);
      var mon=today.getMo nth()+1;

      if(format==dd/mm/yyyy)
      {
      document.getEle mentById(id).in nerHTML = Day+ " "+ (mon);
      }[/CODE]
      Last edited by acoder; Feb 5 '08, 09:09 AM. Reason: Added code tags

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Originally posted by praveen1983
        [CODE=javascript]var today=new Date();
        var t=today.toStrin g().split('U',2 );
        var month=t[0].split(' ',4);
        var mon=today.getMo nth()+1;

        if(format==dd/mm/yyyy)
        {
        document.getEle mentById(id).in nerHTML = Day+ " "+ (mon);
        }[/CODE]
        This code wouldn't work. Why are you splitting on the letter U?

        Ps. please use code tags when posting code. Thanks!

        Comment

        Working...