Search code examples
javascriptdateutcgmt

Remove time from GMT time format


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 out everything except for the actual date?


Solution

  • 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);