So I have this code:
$laikas = htmlspecialchars($_POST['rodymolaikas']);
$laikas = date( "H:i:s", strtotime( $laikas ) );
$videotrukme = $_POST['videotrukme'];
$videotrukme1 = round($videotrukme);
$videotrukme2 = sprintf('%02d:%02d:%02d', ($videotrukme1/3600),($videotrukme/60%60), $videotrukme%60);
$laikas_end = date('H:i:s', strtotime($laikas) + strtotime($videotrukme2));
echo $laikas_end;
The variables are even to:
$laikas = 17:00:00;
$videotrukme2 = 00:01:12;
But the answer I get is:
laikas_end = 02:00:00
Could you please tell me why is that happening?
You can accomplish time addition like thi
<?php
$laikas = htmlspecialchars($_POST['rodymolaikas']);
$laikas = date( "H:i:s", strtotime( $laikas ) );
$videotrukme2 = $_POST['rodymolaikas'];
$videotrukme2 = date( "H:i:s", strtotime( $videotrukme2 ) );
$h = strtotime($laikas);
$h2 = strtotime($videotrukme2);
$minute = date("i", $h2);
$second = date("s", $h2);
$hour = date("H", $h2);
$convert = strtotime("+$minute minutes", $h);
$convert = strtotime("+$second seconds", $convert);
$convert = strtotime("+$hour hours", $convert);
$laikas_end = date('H:i:s', $convert);
echo $laikas_end;
?>