Skip to content

Instantly share code, notes, and snippets.

@mdp
Created May 29, 2014 16:54
Show Gist options
  • Save mdp/e733fff433ccbe3d41cd to your computer and use it in GitHub Desktop.
Save mdp/e733fff433ccbe3d41cd to your computer and use it in GitHub Desktop.
Local time in javascript
function localTime(offset) {
var d = new Date();
var utc = d.getTime() + (d.getTimezoneOffset() * 60000);
return new Date(utc + (3600000*offset));
}
localTime(5.5);
localTime(-8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment