0

Hi,

I'm trying to substract the hours of the time with the hours of the begining of an event, and print how many time is left.

Can someone help me?

//Pre├žo Viagens
$partida=$viagens['HoraPartida'];

$horapartida = explode(":", $partida);
echo $horapartida[0];

$horasistema = date("G");   //hora sistema

$difhoras=$horasistema - $horapartida;
4
Contributors
3
Replies
30
Views
4 Years
Discussion Span
Last Post by flashhtml5
0

can you please tell what data was there in $viagens['HoraPartida'].

Because until that we can't tell solution to your problem.

0

can you please tell what data was there in $viagens['HoraPartida'].

My guess would be a time string in hours and minutes: "hh:mm". A better question would be what result is the OP expecting and how does the code not produce the correct result?

0

This works fine:

    $partida = "10:23";
    $horapartida = explode(":", $partida);
    print "horapartida: " . $horapartida[0] . "\n";;
    $horasistema = date("G"); //hora sistema
    $difhoras=$horasistema - $horapartida[0];
    print "Difhoras: " . $difhoras . "\n";

Notice that the OP was missing the array element selector [] in
his original line 9.

Regards,
Shawn

Edited by flashhtml5: typo

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.