Skip to content

Instantly share code, notes, and snippets.

@che-wf
Created August 20, 2015 04:49
Show Gist options
  • Select an option

  • Save che-wf/7c2525b01dc66d7fd708 to your computer and use it in GitHub Desktop.

Select an option

Save che-wf/7c2525b01dc66d7fd708 to your computer and use it in GitHub Desktop.
Convert Time from Argentine Time to Local Time
<html>
<head>
<title>Convert Time from Argentine Time to Local Time</title>
</head>
<body>
<span id="time"></span>
<script>
function toLocalTime(time) {
var splitTime = time.split(':');
var currDate = new Date();
var y = currDate.getFullYear(),
mo = currDate.getMonth(),
d = currDate.getDate(),
h = parseInt(splitTime[0]) + 3,
m = splitTime[1],
s = 0;
var newTime = new Date(Date.UTC(y, mo, d, h, m, s)).toLocaleTimeString('en-US');
return newTime;
}
document.getElementById('time').innerHtml = toLocalTime('9:00');
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment