Nodejs Date Short Format toShortDateString()

Here you can find the source of toShortDateString()

Method Source Code

Date.prototype.toShortDateString = function() {
    return this.getFullYear() + "/" + (this.getMonth() + 1) + "/" + this.getDate();
};

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 () {  
      var tempStr = '';
      var dayOfTheMonth = this.getDate();
      var month = this.getMonth();
      var year = this.getFullYear();
        tempStr += dayOfTheMonth.padWithDigits(2) + '-' + month.padWithDigits(2) + '-' + year.padWithDigits(4);
      return tempStr;  
    };