One simple way to 'add' 30 minutes is to create a second date object (mostly for demonstration) and set the minutes to minutes + 30
. This will account for adjusting the hour as well if the first time is less than 30 minutes from the next hour. (i.e., 4:45
to 5:15
)
const first = new Date();
console.log("first date :", first.toString());
const second = new Date(first);
second.setMinutes(const newMinutes = second.getMinutes() + 3030;
console.log("new minutes:", newMinutes);
second.setMinutes(newMinutes);
console.log("second date:", second.toString());