Skip to content

Instantly share code, notes, and snippets.

@pthrasher
Forked from tebriel/formattime.js
Created January 31, 2012 03:20
Show Gist options
  • Save pthrasher/1708526 to your computer and use it in GitHub Desktop.
Save pthrasher/1708526 to your computer and use it in GitHub Desktop.
format time
function formatTime(e)
{
var _hour = e.getHours(),
_min = e.getMinutes(),
_ampm = +_hour >= 12 ? " PM" : " AM",
_nice_hour = ((+_hour % 12)+"").replace(/^0$/, "12");
return _nice_hour + ":" + _min + _ampm;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment