10 examples of 'add one day to date in javascript' in JavaScript

Every line of 'add one day to date in javascript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
141function add1Day(day) {
142 return moment(day).add(1, "days");
143}
441function nextDay(date) {
442 const day = new Date(date);
443 day.setDate(day.getDate() + 1);
444 return day;
445}
71addDate() {// 添加日期
72 for (let i = this.opt.minYear; i < this.opt.maxYear; i++) { // 添加年
73 this.years.push({
74 key: i.toString(),
75 value: i + this.opt.yyUnit
76 });
77 }
78 for (let j = 1; j <= 31; j++) { // 添加天
79 this.days.push({
80 key: j.toString(),
81 value: j + this.opt.ddUnit
82 });
83 }
84 for (let k = 1; k <= 12; k++) { // 添加月
85 this.months.push({
86 key: k.toString(),
87 value: k + this.opt.MMUnit
88 });
89 }
90 for (let l = 1; l <= 24; l++) { // 添加小时
91 this.hours.push({
92 key: l.toString(),
93 value: l + this.opt.hhUnit
94 });
95 }
96 for (let m = 1; m <= 60; m++) { // 添加分&秒
97 this.minutes.push({
98 key: m.toString(),
99 value: m + this.opt.mmUnit
100 });
101 this.seconds.push({
102 key: m.toString(),
103 value: m + this.opt.ssUnit
104 });
105 }
106}
26function nextMonday(d) {
27 let monday = new Date(d);
28 monday.setDate(monday.getDate() + (1 + 7 - monday.getDay()) % 7);
29 return monday;
30}
56function _dayToDateTime(date) {
57 return [date.getFullYear(), _lpad(date.getMonth()+1, 2, '0'), _lpad(date.getDate(), 2, '0')].join("-");
58}
171function setDate (date, day) {
172 return _getMoment(date).date(day).toDate()
173}
114export function addYears (d, years) {
115 const newDate = cloneDate(d);
116 newDate.setFullYear(d.getFullYear() + years);
117 return newDate;
118}
3export function addDays(date, days) {
4 const d = new Date(date.valueOf());
5 d.setDate(d.getDate() + days);
6 return d;
7}
40function getNextSunday(date) {
41 var date = new Date(date); //clone date to avoid changes in the parameter
42 var dayOfWeek = date.getDay();
43 var diff = (dayOfWeek == 0 ? 0 : 7 - dayOfWeek);
44
45 return new Date(date.setDate(date.getDate() + diff));
46}
24function formatDay(date) {
25 d = new Date(date * 1000);
26 return d.getDate() + " " + months[d.getMonth()];
27}

Related snippets