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

后端 未结 8 1763
余生分开走
余生分开走 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条回答
  •  误落风尘
    2020-12-14 00:07

    date.toLocaleDateString('en-US') works great. Here's some more information on it: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString

提交回复
热议问题