Skip to content

how to change minutes to date format in javascript?

const date = new Date();
const setTimer = date.setMinutes(date.getMinutes() + time);
console.log(time); //5
console.log(date); // Sun May 02 2021 18:36:54 GMT+0900
console.log(setTimer); //1619948214235  <---why?

i did like this

but how can i convert “setTimer” to normal format ?


You can set the minutes using setMinutes and then using getMinutes get the updated value and store it in setTimer.

const date = new Date();
date.setMinutes(date.getMinutes() + 5);
const setTimer = date.getMinutes()