-1

I need to add minutes in an specif hour. It is in js. I have a hour = 09:30 and need to add more 30minutes, but the output shows me '10:0', one '0' less.

Soma_minutos: function(hour, minutes) {
// This case  minutes = 30;  hour = 09:30


    var tempo, hora_nova, horas = '';

    tempo     = new Date("T"+hora);
    tempo.setTime(tempo.getTime() + minutos*60000);
    horas     = tempo.getHours().toString(); // 10
    minutos   = tempo.getMinutes().toString(); // 0

    hora_nova = horas + ':' + minutos;

    return hora_nova;

},
Matheus Hahn
  • 17
  • 1
  • 7

1 Answers1

1

something like this:

if (minotos.length = 1)
{
    minotos = "0" + minotos;
}
NoOorZ24
  • 2,914
  • 1
  • 14
  • 33