How to convert a full date to a short date in javascript?

后端 未结 8 1753
余生分开走
余生分开走 2020-12-13 23:40

I have a date like this Monday, January 9, 2010

I now want to convert it to

1/9/2010 mm/dd/yyyy

I tried to do this

    var startDat         


        
8条回答
  •  萌比男神i
    2020-12-14 00:03

    I was able to do that with :

    var dateTest = new Date("04/04/2013");
    dateTest.toLocaleString().substring(0,dateTest.toLocaleString().indexOf(' '))
    

    the 04/04/2013 is just for testing, replace with your Date Object.

提交回复
热议问题