i'm looking to handle a script wich has to add 10 years to the current timestamp in javascript...
But when i try this:
Date.now() + /* 10 years in seconds */ 315569520
It doens't work... Is there anyway to implement it ?
i'm looking to handle a script wich has to add 10 years to the current timestamp in javascript...
But when i try this:
Date.now() + /* 10 years in seconds */ 315569520
It doens't work... Is there anyway to implement it ?
Do like:
const dt = new Date;
dt.setFullYear(dt.getFullYear()+10);
console.log(dt.toString());
plz check this url. You can find your solution. https://www.w3resource.com/javascript-exercises/javascript-date-exercise-41.php
it's very simple you can achieve in two line code:
`let timestamp = new Date();
timestamp.setFullYear(timestamp.getFullYear() + 10);
console.log(timestamp);`
You need to use a Date constructor to create the date from the value you calculated.
new Date(Date.now() + 315569520 * 1000)
You need to add the value of 10 years in milliseconds, and then pass the new value to a Date constructor