0

i would like to sum this time 15-00-00 with this which is a string: 4 minutes I don't know how to convert the 4 minutes into a correct format and the 15-00-00 into 15:00:00

here's my code :

var reservationDate = '<?= $selectDateReservation[0] ?>';
var reservationTime = '<?= $selectTimeReservation[0] ?>';
var getDuration = '<?= $selectDuration[0] ?>' // returns: "4 minutes"
console.log(reservationDate); // returns the date: 19-05-17
console.log(reservationTime); // returns the time: 15-00-00
Haroon nasir
  • 648
  • 1
  • 7
  • 21
LgCat
  • 11
  • 1

1 Answers1

0

Try something like this

var date = new Date();
var minutes = 4

date.setMinutes(date.getMinutes() + minutes);
console.log(date) // Should return your time with the minutes added to it

You could convert the minutes with the getMinutes() method.

Elomin
  • 11
  • 2
  • For the conversion, maybe [this](https://stackoverflow.com/questions/10837022/convert-php-date-into-javascript-date-format) will help you. That way you can actually use the `getMinutes()` method – Elomin May 02 '19 at 10:46