Skip to content

Instantly share code, notes, and snippets.

@drzax
Created August 28, 2015 06:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drzax/61ba2801604f37bd8b5a to your computer and use it in GitHub Desktop.
Save drzax/61ba2801604f37bd8b5a to your computer and use it in GitHub Desktop.
A quick 12 hour time date formatter for javascript
function formatTime(date) {
var hrs = date.getHours();
return ((hrs + 11) % 12) + 1 + ':' + ("0"+date.getMinutes()).substr(-2,2) + ((hrs > 11) ? 'pm' : 'am');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment