Subtracting two hours in PHP
Solved
ThePico20
Posted messages
110
Registration date
Status
Member
Last intervention
-
ThePico20 Posted messages 110 Registration date Status Member Last intervention -
ThePico20 Posted messages 110 Registration date Status Member Last intervention -
Hello,
I would like to subtract two hours,
I have this code (which works partially):
It is supposed to display the remaining time before the start of a live session: ($info['debut'] = stored in a database & $heure being the current time) But it doesn't work, for example:
Start displays 01:12:44 (it would therefore display an hour too much, but why?)
Could someone help me?
Configuration: Windows 7 / Chrome 32.0.1700.76
--
I'm sorry to disappoint you, life is not found in tutorials.
I would like to subtract two hours,
I have this code (which works partially):
$h1 = strtotime($heure); $h2 = strtotime($info['debut']); $Start = date("H:i:s", $h2-$h1); echo $Start; It is supposed to display the remaining time before the start of a live session: ($info['debut'] = stored in a database & $heure being the current time) But it doesn't work, for example:
$h1 = strtotime(13:17); $h2 = strtotime("13:30:00"); $Start = date("H:i:s", $h2-$h1); echo $Start Start displays 01:12:44 (it would therefore display an hour too much, but why?)
Could someone help me?
Configuration: Windows 7 / Chrome 32.0.1700.76
--
I'm sorry to disappoint you, life is not found in tutorials.
3 answers
-
You can use gmdate instead of date, you won't have the offset anymore.
$h1 = strtotime("13:17:00");
$h2 = strtotime("13:30:00");
$Start = gmdate("H:i:s", $h2-$h1);
echo $Start -
My apologies, in my request I just sorted the date in descending order and the beginning in ascending order.
--
Sorry to disappoint you, life is not found in tutorials. -
However, I don't want to create another topic, but I have in my database the column "debut" and the column "fin" that correspond to the start and end of a live stream. I would like to display the next 4 live streams that are going to happen. For that, I am using this loop:
$reponse = $bdd->query("SELECT * FROM planning ORDER BY date DESC LIMIT 0, 4"); // SQL QUERY while($info = $reponse->fetch()) // LOOP THAT DISPLAYS THE NEXT 4 LIVE STREAMS { if($date<=$info['date']) { list($annee,$mois,$jour) = explode('-',$info['date']); // FETCHING THE DAY $day = date("l", $jour); $day = TranslateDate($day); $month = date("F", $mois); $month = TranslateDate($month); list($heureD,$minuteD,$secondeD) = explode(':',$info['debut']); list($heureF,$minuteF,$secondeF) = explode(':',$info['fin']); echo "
Live by ".$info['streamer'].""; // DISPLAYING THE NEXT 4 LIVE STREAMS } }
on ".$info['games']."
On ".$day." ".$jour." ".$month." from ".$heureD.":".$minuteD." to ".$heureF.":".$minuteF.".
But it displays in any order. (The next 4 yes but in any order)
--
Sorry to disappoint you, life is not found in Tutorials.