Remove time from GMT time format

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

    If you want to keep using Date and not String you could do this:

    var d=new Date(); //your date object
    console.log(new Date(d.setHours(0,0,0,0)));
    

    -PS, you don't need a new Date object, it's just an example in case you want to log it to the console.

    http://www.w3schools.com/jsref/jsref_sethours.asp

提交回复
热议问题