2

We are currently using the following in our code to get the UTC Time:

    date.format("isoDateTime")

How do you get the UTC Time in javascript?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Nate Pet
  • 44,246
  • 124
  • 269
  • 414
  • 1
    Posible duplicate of http://stackoverflow.com/questions/9756120/utc-timestamp-in-javascript – Moob Oct 08 '13 at 20:50
  • Your question answered here: http://stackoverflow.com/questions/8047616/get-a-utc-timestamp-in-javascript Hope it helps – David Levin Oct 08 '13 at 20:50

3 Answers3

2

Date objects come with a toISOString() method. Assuming date is your JavaScript date object, you can simply call:

date.toISOString();
James Donnelly
  • 126,410
  • 34
  • 208
  • 218
1

.toISOString() is good for string. If you need JavaScript date object use

    var getUtcTime = function() {
        var d = new Date();
        return d.getTime() + d.getTimezoneOffset() * 60 * 1000;
    };
Maksym Kozlenko
  • 10,273
  • 2
  • 66
  • 55
0

var d=new Date(Date.UTC(2013,10,09));

Yash
  • 1
  • 3