convert format date from "YYYY-mm-dd" to "dd-mm-YYYY"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maminx
    New Member
    • Jul 2008
    • 77

    #1

    convert format date from "YYYY-mm-dd" to "dd-mm-YYYY"

    Hello all, asking again
    i want to convert format date from "YYYY-mm-dd" to "dd-mm-YYYY"

    example from "2008-08-16" become format date like this one "16-08-2008"

    is it anyone who has this library??thanks
  • rnd me
    Recognized Expert Contributor
    • Jun 2007
    • 427

    #2
    Code:
    function convertDate(dateString){
    var p = dateString.split(/\D/g)
    return [p[2],p[1],p[0] ].join("-")
    }
    
    convertDate("2001-9-11")//"11-9-2001"

    Comment

    • maminx
      New Member
      • Jul 2008
      • 77

      #3
      Originally posted by rnd me
      Code:
      function convertDate(dateString){
      var p = dateString.split(/\D/g)
      return [p[2],p[1],p[0] ].join("-")
      }
      
      convertDate("2001-9-11")//"11-9-2001"

      thanks...it works well

      Comment

      • Denish13
        New Member
        • Jun 2014
        • 1

        #4
        following function used to convert one date formate to another

        Code:
        function FormateDate(oldDate)
        {
        var newDate=new Date(oldDate.toString().split("-").reverse().join("-"));
        return newDate;
        }
        Last edited by Rabbit; Jun 29 '14, 07:26 AM. Reason: Please use [code] and [/code] tags when posting code or formatted data.

        Comment

        Working...