1

In Javascript console when running new Date() it returns something like:

Wed Jan 13 2021 18:30:00 GMT+0000 (Greenwich Mean Time)

but in node.js it returns:

2021-01-13T18:32:21.182Z

So my question is, how in node.js would I get time in the format of the browser? Is the only way to format it like in this question?

GAP2002
  • 870
  • 4
  • 20

1 Answers1

0

I think you are looking for toUTCString()

console.log(new Date().toUTCString())

It will return you the time in the UTC format that you want.

Hamza Anis
  • 2,475
  • 1
  • 26
  • 36
  • Yes, this definitely takes me a lot closer, is there any way to get the `GMT+0000 (Greenwich Meantime)` section as well? – GAP2002 Jan 13 '21 at 19:04