Nodejs Date Get getMidnight()

Here you can find the source of getMidnight()

Method Source Code

Date.getToday = function() {
   var now = new Date();
   return now.getMidnight();
};

Date.prototype.getMidnight = function() {
   return new Date( this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
};

Related

  1. getFullDate()
    Date.prototype.getFullDate = function(){  
      if (this.getDate() < 10) {
        return '0' + this.getDate();
      return this.getDate();
    };
    
  2. getFullDate(separator)
    Date.prototype.getFullDate = function(separator) {
        separator = separator ? separator : '-';
        return this.getFullYear()+separator+this.getMonthFormatted()+separator+this.getDayFormatted();
    };
    
  3. getGMTOffset()
    Date.prototype.getGMTOffset = function () {
        return (this.getTimezoneOffset() > 0 ? "-" : "+")
            + String.leftPad(Math.floor(this.getTimezoneOffset() / 60), 2, "0")
            + String.leftPad(this.getTimezoneOffset() % 60, 2, "0");
    
  4. getLastDate()
    Date.prototype.getLastDate = function() {
        return new Date(this.getFullYear(), this.getMonth() + 1, 0).getDate();
    
  5. getLocalDateObject()
    Date.prototype.getLocalDateObject = function () {
        return new Date(this.toLocaleString())
    
  6. getNextDate(i)
    Date.prototype.getNextDate = function(i){
      return new Date(new Date().setDate(new Date().getDate()+i));
    };
    
  7. getNumberDate()
    Date.prototype.getNumberDate = function() {
      var month = this.getMonth() + 1;
      var day = this.getDate();
      var year = this.getFullYear();  
      return month +"/"+ day +"/"+ year;
    
  8. getPreviousDate(i)
    Date.prototype.getPreviousDate = function(i){
      return new Date(new Date().setDate(new Date().getDate()-i));
    };
    
  9. getSecondsFormatted(number)
    Date.prototype.getSecondsFormatted = function(number) {
        var second = this.getSeconds();
        return second < 10 ? '0' + second : second;
    };