Skip to content

Instantly share code, notes, and snippets.

@kn9ts
Created December 11, 2016 10:54
Show Gist options
  • Save kn9ts/88699ff38263c5984950ccb6b4671165 to your computer and use it in GitHub Desktop.
Save kn9ts/88699ff38263c5984950ccb6b4671165 to your computer and use it in GitHub Desktop.
// USAGE
// var newDate = new Date();
// var datetime = "LastSync: " + newDate.today() + " @ " + newDate.timeNow();
// For todays date;
Date.prototype.today = function() {
return ((this.getDate() < 10) ? "0" : "") + this.getDate() + "/" + (((this.getMonth() + 1) < 10) ? "0" : "") + (this.getMonth() + 1) + "/" + this.getFullYear();
}
// For the time now
Date.prototype.timeNow = function() {
return ((this.getHours() < 10) ? "0" : "") + this.getHours() + ":" + ((this.getMinutes() < 10) ? "0" : "") + this.getMinutes() + ":" + ((this.getSeconds() < 10) ? "0" : "") + this.getSeconds();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment