Skip to content

Instantly share code, notes, and snippets.

@a-pasquale
Last active December 2, 2015 03:38
Show Gist options
  • Save a-pasquale/23668e53e28a01de862c to your computer and use it in GitHub Desktop.
Save a-pasquale/23668e53e28a01de862c to your computer and use it in GitHub Desktop.
Localtime
<div>
<label id="date" for="date">10:00 AM PST</label>
</div>
Localtime
---------
Display a date in the local timezone.
A [Pen](http://codepen.io/apasquale/pen/QyLKRx) by [Andrew Pasquale](http://codepen.io/apasquale) on [CodePen](http://codepen.io/).
[License](http://codepen.io/apasquale/pen/QyLKRx/license).
var options = { timeZoneName: 'short' };
$('#date').html( new Date( Date.UTC(2015, 12, 11, 18, 0)).toLocaleTimeString('en-US', options).replace(/:\d+ /, ' ') );
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
div {
width: 200px;
margin: 100px auto;
padding: 50px;
text-align: center;
background-color: steelblue;
border-radius: 20px;
}
label {
font-family: Arial;
font-size: 1.4em;
color: #ffffff;
margin-left: 10px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment