Remove time from GMT time format

前端 未结 8 2508
有刺的猬
有刺的猬 2021-02-18 23:01

I am getting a date that comes in GMT format, Fri, 18 Oct 2013 11:38:23 GMT. The problem is that the time is messing up the timeline that I am using.

How can I strip ou

8条回答
  •  迷失自我
    2021-02-18 23:40

    Well,

    Here is my Solution

    let dateString = 'Mon May 25 01:07:00 GMT 2020';
    let dateObj = new Date(dateString);
    
    console.log(dateObj.toDateString());
    // outputs Mon May 25 2020

    See its documentation on MDN https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString

提交回复
热议问题