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
  • 34,719
  • 24
  • 185
  • 251
Nate Pet
  • 41,226
  • 116
  • 259
  • 398
  • 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
  • 122,518
  • 33
  • 200
  • 204
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
  • 9,961
  • 2
  • 64
  • 54
0

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

Yash
  • 1
  • 3