Skip to content

Instantly share code, notes, and snippets.

@FrancoAguilera
Created December 6, 2019 18:33
Show Gist options
  • Save FrancoAguilera/b1e06753abb4c99670e7148974ec4f5b to your computer and use it in GitHub Desktop.
Save FrancoAguilera/b1e06753abb4c99670e7148974ec4f5b to your computer and use it in GitHub Desktop.
Date.prototype.addHours = function (h) {
this.setHours(this.getHours() + h);
return this;
}
var japanTimeOffset = 9;
var timeZoneOffset = new Date().getTimezoneOffset() / 60;
var japanCurrentTIme = new Date().addHours(japanTimeOffset + timeZoneOffset);
var inWorkingHours = japanCurrentTIme.getHours() >= 8 && japanCurrentTIme.getHours() < 20;
console.log('Japan current time --> ' + japanCurrentTIme.toTimeString());
console.log('Japan bussines hours --> ' + inWorkingHours);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment