JavaScript
x
6
1
const date = new Date();
2
const setTimer = date.setMinutes(date.getMinutes() + time);
3
console.log(time); //5
4
console.log(date); // Sun May 02 2021 18:36:54 GMT+0900
5
console.log(setTimer); //1619948214235 <---why?
6
i did like this
but how can i convert “setTimer” to normal format ?
Advertisement
Answer
You can set the minutes using setMinutes
and then using getMinutes
get the updated value and store it in setTimer
.
JavaScript
1
4
1
const date = new Date();
2
date.setMinutes(date.getMinutes() + 5);
3
const setTimer = date.getMinutes()
4
console.log(setTimer);