Remove time from GMT time format

前端 未结 8 2556
有刺的猬
有刺的猬 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:34

    Like this:

    var dateString = 'Mon Jan 12 00:00:00 GMT 2015';
    dateString = new Date(dateString).toUTCString();
    dateString = dateString.split(' ').slice(0, 4).join(' ');
    console.log(dateString);
    

提交回复
热议问题