Created
March 12, 2012 05:06
-
-
Save noahhendrix/2019916 to your computer and use it in GitHub Desktop.
Sensible additions to the JS date object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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