Skip to main content
added 134 characters in body
Source Link
phentnil
  • 2.3k
  • 2
  • 15
  • 22

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());

One simple way to 'add' 30 minutes is to create a second date object 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.toString());
const second = new Date(first);
second.setMinutes(second.getMinutes() + 30);
console.log(second.toString());

One 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);
const newMinutes = second.getMinutes() + 30;
console.log("new minutes:", newMinutes);
second.setMinutes(newMinutes);
console.log("second date:", second.toString());

Code block adjustment, linking reference, simple ie example
Source Link
phentnil
  • 2.3k
  • 2
  • 15
  • 22

One of the simplest wayssimple way to 'add' 30 minutes is to create a second date object and set the minutesset 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.toString());
const second = new Date(first);
second.setMinutes(second.getMinutes() + 30);
console.log(second.toString());

One of the simplest ways to 'add' 30 minutes is to create a second date object 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:

const first = new Date();
console.log(first.toString());
const second = new Date(first);
second.setMinutes(second.getMinutes() + 30);
console.log(second.toString());

One simple way to 'add' 30 minutes is to create a second date object 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.toString());
const second = new Date(first);
second.setMinutes(second.getMinutes() + 30);
console.log(second.toString());

Source Link
phentnil
  • 2.3k
  • 2
  • 15
  • 22

One of the simplest ways to 'add' 30 minutes is to create a second date object 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:

const first = new Date();
console.log(first.toString());
const second = new Date(first);
second.setMinutes(second.getMinutes() + 30);
console.log(second.toString());