Nodejs Date Get getDisplayDate()

Here you can find the source of getDisplayDate()

Method Source Code

Date.prototype.getDisplayDate = function()
{
   return this.getDate() > 9 ? "" : "0" + this.getDate();
};

Date.prototype.getDisplayMonth = function()
{
   return this.getMonth() > 9 ? "" : "0" + this.getMonth();
};

Date.prototype.addMilliseconds = function(count)
{
   this.setMilliseconds(this.getMilliseconds() + count);
};

Date.prototype.addSeconds = function(count)
{
   this.setSeconds(this.getSeconds() + count);
};

Date.prototype.addMinutes = function(count)
{
   this.setMinutes(this.getMinutes() + count);
};

Date.prototype.addHours = function(count)
{
   this.setHours(this.getHours() + count);
};

Date.prototype.addDate = function(count)
{
   this.setDate(this.getDate() + count);
};

Date.prototype.addMonth = function(count)
{
   this.setMonth(this.getMonth() + count);
};

Date.prototype.addYear = function(count)
{
   this.setYear(this.getFullYear() + count);
};

Related

  1. getDateDifference(otherDate)
    Date.prototype.getDateDifference = function(otherDate){
      var oneDay = 1000*3600*24;
      var d = new Date(+this);
      d.setHours(0,0,0,0);
      otherDate.setHours(0,0,0,0);
      var timeDiff = d.getTime() - otherDate.getTime();
      return Math.floor(timeDiff/oneDay);
    
  2. getDateOffset(target)
    Date.prototype.getDateOffset = function(target) {
        var milliSeconds = target.getTime() - this.getTime();
        return Math.ceil(milliSeconds/1000/60/60/24);
    };
    
  3. getDateOrdinal()
    Date.prototype.getDateOrdinal = function()
      var n = this.getDate();
      var ord = 'th';
      if (n % 10 == 1 && n % 100 != 11)
        ord = 'st';
      else if (n % 10 == 2 && n % 100 != 12)
    ...
    
  4. getDateParts()
    var convertMonthIndexToStr = function(monthIndex) {
      var map = [
        'January', 'February', 'March', 'April',
        'May', 'June', 'July', 'August',
        'September', 'October', 'November', 'December'
      ];
      return map[monthIndex];
    var convertDayOfWeekIndexToStr = function(dayOfWeekIndex) {
    ...
    
  5. getDateStamp()
    Date.prototype.getDateStamp = function() {
      let month = this.getMonth()+1;
      let day = this.getDate();
      return [this.getFullYear(),
        (month > 9 ? '' : '0') + month,
        (day > 9 ? '' : '0') + day
      ].join('');
    };
    
  6. getExcelTS()
    Date.prototype.getExcelTS = function(){
      var epoch = new Date(1899,11,31);
      var dt = this.setDate(this.getDate()+1);
      var ts = (dt-epoch)/(1000*60*60*24);
      return ts;
    };
    
  7. getFormat()
    Date.prototype.getFormat = function()
        return (this.getDate() < 10 ? '0' : '') + this.getDate() + '/' +
               (this.getMonth() < 10 ? '0' : '') + this.getMonth() + '/' +
               this.getFullYear() +
               ' | ' +
               (this.getHours() < 10 ? '0' : '') + this.getHours() + ':' +
               (this.getMinutes() < 10 ? '0' : '') + this.getMinutes() + ':' +
               (this.getSeconds() < 10 ? '0' : '') + this.getSeconds();
    ...
    
  8. getFormat()
    Date.prototype.getFormat = function()
        return (this.getDate() < 10 ? '0' : '') + this.getDate() + '/' +
               (this.getMonth() < 10 ? '0' : '') + this.getMonth() + '/' +
               this.getFullYear() +
               ' | ' +
               (this.getHours() < 10 ? '0' : '') + this.getHours() + ':' +
               (this.getMinutes() < 10 ? '0' : '') + this.getMinutes() + ':' +
               (this.getSeconds() < 10 ? '0' : '') + this.getSeconds();
    ...
    
  9. getFormated()
    Date.prototype.getFormated = function() {
      function pad(number) {
        if (number < 10) return '0' + number;
        return number;
      var d = this.getFullYear() + '-' + pad(this.getMonth() + 1) + '-' + pad(this.getDate());
      var t = pad(this.getHours()) + ':' + pad(this.getMinutes()) + ':' + pad(this.getSeconds());
      return d + ' ' + t;
    };
    ...