Nodejs Month Calculate getMonth2()

Here you can find the source of getMonth2()

Method Source Code

Date.prototype.getMonth2 = function () {
   var month = this.getMonth() + 1;
   return (month < 10 ? '0' : '') + month;
};

Related

  1. getAbbrMonth()
    Date.prototype.getAbbrMonth = function() {
      switch(this.getMonth()) {
        case 0: return 'Jan';
        case 1: return 'Feb';
        case 2: return 'March';
        case 3: return 'Apr';
        case 4: return 'May';
        case 5: return 'Jun';
        case 6: return 'July';
    ...
    
  2. getCurrentMonthDays()
    Date.prototype.getCurrentMonthDays = function(){
            var thisTime = this.getTime();
            if(this.getMonth() == 11){
                this.setYear(this.getYear()+1);
                this.setMonth(0);
            else{
                this.setMonth(this.getMonth()+1);
            var currentDays = parseInt((this.getTime()-thisTime)/1000/60/60/24);
            this.setTime(thisTime);
            return currentDays; 
    
  3. getFirstDayOfMonth()
    Date.prototype.getFirstDayOfMonth = function () {
        var day = (this.getDay() - (this.getDate() - 1)) % 7;
        return (day < 0) ? (day + 7) : day;
    
  4. getLastDateInMonth(months)
    Date.prototype.getLastDateInMonth = function (months){
      months = parseInt(months);
      return new Date(this.getFullYear(), this.getMonth() + (months || 0) + 1, 0);
    
  5. getLastDayOfMonth()
    Date.prototype.getLastDayOfMonth = function () {
        var day = (this.getDay() + (Date.daysInMonth[this.getMonth()] - this.getDate())) % 7;
        return (day < 0) ? (day + 7) : day;
    
  6. getMonthEnd()
    Date.prototype.getMonthEnd = function () {
      return new Date(this.getFullYear(), this.getMonth() + 1, 0);
    };
    
  7. getMonthStart()
    Date.prototype.getMonthStart = function () {
      return new Date(this.getFullYear(), this.getMonth(), 1);
    };
    
  8. getShortMonth()
    Date.prototype.getShortMonth = function () {
       return ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][this.getMonth()];
    };
    
  9. getShortMonthName()
    Date.prototype.getShortMonthName = function () {
      var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
        "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
      ];
      return monthNames[this.getMonth()];
    };