I am adding some epoch time to my date variable and then converting it to iso to put it inside db. but my code is not geting correct time. my code is not stoping to execute => var releaseDate = new Date(epochDate).toISOString(); how should I make it happen
my code output is
epoch and now =
Mon Dec 21 2020 02:16:56 GMT+0530 (IST)604800000
1618003233700
2020-12-20T20:46:56.000Z
date should be today + 7 days but it didn't change.
async function schedule(data, epochDate) {
const endpoint = config.main+"/schedule"
const opt = {
headers: {
"id": 0
}
}
//add 7 days in epoch time milliseconds
epochDate += 604800000;
const now = Date.now();
console.log("epoch and now =")
console.log(epochDate)
console.log(now)
if(epochDate <= now){
epochDate = now + 604800000;
}
var releaseDate = new Date(epochDate).toISOString();
console.log(releaseDate);
const payload = {
Id: data,
date: new Date(epochDate).toISOString()
}
return await axios.post(endpoint, payload, opt)
.then((result)=> result.data)
.catch((error) => {
console.log('error in axios post catch %j', error.response.data)
throw error
})
}