Skip to content

Instantly share code, notes, and snippets.

@CoeusCC
Last active June 30, 2017 18:38
Show Gist options
  • Save CoeusCC/972b4374373d76ec9d20ef4a1534286a to your computer and use it in GitHub Desktop.
Save CoeusCC/972b4374373d76ec9d20ef4a1534286a to your computer and use it in GitHub Desktop.
function get_formatted_time(time_string) {
const raw = new Date(time_string);
const hour = raw.getHours();
const minute = ("0" + raw.getMinutes()).slice(-2);
const meridian = (hour < 13 ) ? 'AM' : 'PM';
return hour + ':' + minute + ' ' + meridian;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment