Skip to content

Instantly share code, notes, and snippets.

@noahhendrix
Created March 12, 2012 05:06
Show Gist options
  • Save noahhendrix/2019916 to your computer and use it in GitHub Desktop.
Save noahhendrix/2019916 to your computer and use it in GitHub Desktop.
Sensible additions to the JS date object
Date.prototype.get12Hours = function() {
return this.getHours() % 12 || 12;
};
Date.prototype.getMeridanIndicator = function() {
return this.getHours() >= 12 ? 'PM' : 'AM';
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment