Skip to content Skip to sidebar Skip to footer

New Date() For A Specific Timezone In JavaScript

I am working on a project and I was just curious if it was possible in JavaScript to call new Date() for a specific timezone. When I say: var test = new Date(); I debug and I fin

Solution 1:

Checkout moment-timezone.js which makes working with Dates and timezones a lot easier in javascript.

The example on the frontpage shows how it works:

var newYork    = moment.tz("2014-06-01 12:00", "America/New_York");
var losAngeles = newYork.clone().tz("America/Los_Angeles");
var london     = newYork.clone().tz("Europe/London");

newYork.format();    // 2014-06-01T12:00:00-04:00
losAngeles.format(); // 2014-06-01T09:00:00-07:00
london.format();     // 2014-06-01T17:00:00+01:00

Post a Comment for "New Date() For A Specific Timezone In JavaScript"