Skip to content

Instantly share code, notes, and snippets.

@chrisjensen
Last active July 1, 2020 00:20
Show Gist options
  • Save chrisjensen/cb712e5df53809d94322b01af167b4d3 to your computer and use it in GitHub Desktop.
Save chrisjensen/cb712e5df53809d94322b01af167b4d3 to your computer and use it in GitHub Desktop.
const tzc = require('timezonecomplete');
const SingaporeTime = tzc.TimeZone('Singapore/Singapore');
const MelbourneTime = tzc.TimeZone('Australia/Melbourne');
const timeInSingapore = new tzc.DateTime('2019-12-01 08:30', SingaporeTime);
// Same UTC time, different offset
timeInSingapore.convert(MelbourneTime);
// 2019-12-01 11:30am
timeInSingapore.format('yyyy-MM-dd HH:mm');
const timeInSingapore = new tzc.DateTime('2019-12-01 08:30', SingaporeTime);
// 8:30am in Melbourne (different UTC time)
mel = new tzc.DateTime(timeInSingapore.format('YYYY-MM-dd HH:mm'), MelbourneTime);
// 2019-12-01 08:30am
timeInSingapore.format('yyyy-MM-dd HH:mm');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment