Skip to content

Instantly share code, notes, and snippets.

@avegancafe
Last active February 17, 2016 19:10
Show Gist options
  • Select an option

  • Save avegancafe/354559a12e1bb079c3a4 to your computer and use it in GitHub Desktop.

Select an option

Save avegancafe/354559a12e1bb079c3a4 to your computer and use it in GitHub Desktop.
Date.prototype.timeNow = function() {
"use strict";
return ((this.getHours() < 10) ? "0" : "") +
((this.getHours() > 12) ? (this.getHours() - 12) : this.getHours()) + ":" +
((this.getMinutes() < 10) ? "0" : "") + this.getMinutes() + ":" +
((this.getSeconds() < 10) ? "0" : "") + this.getSeconds() + " " +
((this.getHours() > 12) ? "PM" : "AM");
};
@avegancafe
Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment