Nodejs Date Short Format toShortDateString()

Here you can find the source of toShortDateString()

Method Source Code

// Extend Date function
Date.prototype.toShortDateString = function () {  
   var tempStr = '';
    //  ww w. ja  v a2  s  . c o m
   var dayOfTheMonth = this.getDate();
   var month = this.getMonth();
   var year = this.getFullYear();
    
    tempStr += dayOfTheMonth.padWithDigits(2) + '-' + month.padWithDigits(2) + '-' + year.padWithDigits(4);
    
   return tempStr;  
};

Related

  1. toShortDateString()
    String.prototype.toShortDateString = function() {
      var date = new Date(this);
      return date.toDateString().substr(4);
    };
    module.exports = {
      toShortDateString: function(dateString) {
        var date = new Date(dateString);
        return date.getDate() + "/" + (date.getMonth() + 1) + "/" + date.getFullYear();
      },
    ...
    
  2. toShortDateString()
    Date.prototype.toShortDateString = function() {
        return this.getFullYear() + "/" + (this.getMonth() + 1) + "/" + this.getDate();
    };