Add 3 days in milliseconds to the current date in JavaScript

Add 3 days in milliseconds to the current date in JavaScript

In this post we will give you information about Add 3 days in milliseconds to the current date in JavaScript. Hear we will give you detail about Add 3 days in milliseconds to the current date in JavaScriptAnd how to use it also give you demo for it if it is necessary.

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 (3×8640000) 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);

Hope this code and post will helped you for implement Add 3 days in milliseconds to the current date in JavaScript. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US