Javascript Date nextDay()

Description

Javascript Date nextDay()


// next Day/*  ww  w . j ava 2  s . c o  m*/

Date.prototype.nextDay = function() {
  let today = this.getDate();

  return new Date(this.setDate(today + 1));
}

Javascript Date nextDay()


// write a method on instance of a date which will give you next day
Date.prototype.nextDay = function () {
    var currentDate = this.getDate();
    return new Date(this.setDate(currentDate + 1));
}

var today = new Date();
// return UTC time (Coordinated Universal Time) the greenwich meridian in London
console.log(today);//from w ww .j av  a2s  .c  om
console.log(today.nextDay());

Javascript Date nextDay()

'use strict';/*from w w w  . j  av a  2 s . c  o m*/

Date.prototype.nextDay = function () {
 var currentDate = this.getDate();
 console.log('currentDate', currentDate);
 return new Date(this.setDate(currentDate + 1));
};

var d = new Date();

console.log('Next day', d.nextDay());

Javascript Date nextDay()

// Question: How could you write a method on instance of a date which will give you next day?

Date.prototype.nextDay = function() {
 var currentDate = this.getDate();
   return new Date(this.setDate(currentDate + 1));
}

var date = new Date(); 
console.log(date);// w  w w  .  jav a  2s  .co  m
// Sat Oct 31 2015 00:17:52 GMT+1100
console.log(date.nextDay());
// Sun Nov 01 2015 00:17:52 GMT+1100



PreviousNext

Related