Author -  Sai gowtham

Add 3 days in milliseconds to the current date in JavaScript

In this tutorial, we are going to learn about how to add the 3 days in milliseconds to the current date in JavaScript with the help of examples.

Adding 3 days in milliseconds

To add the 3 days in milliseconds to the current date, first we need to multiple the 3 days in milliseconds eg: 1 day contains 86400000 milliseconds. so for 3 days (3x8640000) then add it to the current timestamp.

Here is an example:

const milliSecs = 86400000*3;
const currentTimeStamp = Date.now();
const date =  new Date(currentTimeStamp + milliSecs);

console.log(date);

In the above example:

  • First, we have multipled the 86400000 milliseconds with 3. so we get the 3days in milliseconds.

  • Then we used the built-in Date.now() method to get the current timestamp.

At last we added the current timestamp and milliseconds and passed it to the new Date() constructor. so, we get the date object prior to the 3 days. eg if today is 4 September it returns the date by adding 3 days to it that is 7 September.

We can also write the above code in one line like this:

const date = new Date(Date.now()+86400000*3);
console.log(date);

Css Tutorials & Demos

How rotate an image continuously in CSS

In this demo, we are going to learn about how to rotate an image continuously using the css animations.

How to create a Instagram login Page

In this demo, i will show you how to create a instagram login page using html and css.

How to create a pulse animation in CSS

In this demo, i will show you how to create a pulse animation using css.

Creating a snowfall animation using css and JavaScript

In this demo, i will show you how to create a snow fall animation using css and JavaScript.

Top Udemy Courses

JavaScript - The Complete Guide 2023 (Beginner + Advanced)
JavaScript - The Complete Guide 2023 (Beginner + Advanced)
116,648 students enrolled
52 hours of video content
$14.99 FROM UDEMY
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
631,582 students enrolled
49 hours of video content
$24.99 FROM UDEMY
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
203,937 students enrolled
31.5 hours of video content
$14.99 FROM UDEMY