Javascript reformat date string

前端 未结 5 1951
再見小時候
再見小時候 2020-12-21 01:14

I have this date fromat:

Mon Feb 02 2015 05:18:44 GMT+0000 (UTC) 

How can I reformat it to something more friendlier such as 2/2/2015

5条回答
  •  有刺的猬
    2020-12-21 01:53

    Use this awesome library. Moment JS

    For your case it would be some thing link

    var dateString = 'Mon Feb 02 2015 05:18:44 GMT+0000';
    var date = new Moment(dateString);
    
    alert(date.format('MM/dd/YYYY'));
    

提交回复
热议问题