0

I currently have this code below in javascript but it is currently at it's default timezone which is PST but I want it to be UTC by default or a way to convert it to UTC.

What are some ways around it?

var now = new Date().getTime();
Josh
  • 99
  • 2
  • 9
  • 1
    Possible duplicate of [How do you convert a JavaScript date to UTC?](https://stackoverflow.com/questions/948532/how-do-you-convert-a-javascript-date-to-utc) – Igor Apr 15 '19 at 17:06
  • 1
    Possible duplicate of [Get a UTC timestamp](https://stackoverflow.com/questions/8047616/get-a-utc-timestamp) – Sara Fuerst Apr 15 '19 at 17:07
  • 1
    Remember to read through https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date because if you don't know how to do something, (re)familiarise yourself with which built-in functionality you have available. – Mike 'Pomax' Kamermans Apr 15 '19 at 17:08

1 Answers1

1

You can use var now = new Date().toISOString();

var now = new Date().toISOString();
console.log(now)
Hien Nguyen
  • 24,551
  • 7
  • 52
  • 62