
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Increment a Date in JavaScript Without Using Any Libraries
To add one day to date in JS, the setDate function is the best way. You can create the following function on the Date prototype to add days to the date.
Example
Date.prototype.addDays = function(days) { let d = new Date(this.valueOf()); d.setDate(d.getDate() + days); return d; } let date = new Date(); console.log(date.addDays(1));
This will log the next day.
Advertisements