-2

I have a string date like this:

2018-08-26T00:00:00.000Z

Is there a way that I can format it so it looks similar to this format?

Fri, 24 Aug 2018 09:30:00 GMT 
E, d MMM yyyy HH:mm:ss zzz
31piy
  • 23,323
  • 6
  • 47
  • 67
KevinVuD
  • 581
  • 2
  • 5
  • 25

1 Answers1

3

Simply construct a Date object, and then you can use Date.prototype.toUTCString to format the string in the GMT format:

var date = new Date('2018-08-26T00:00:00.000Z');
console.log(date.toUTCString());
31piy
  • 23,323
  • 6
  • 47
  • 67
  • Until ECMAScript 2018 (ed 9) *toUTCString* was implementation dependent, so older and non-conforming browsers may not return the required format. – RobG Sep 01 '18 at 05:31