Level 67
You're mixing 2 different languages. That doesn't work. A javascript setTimeout() won't execute php code. Javascript runs/lives in the browser. PHP runs/lives on the server.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
i work with both javascript and php but setTimeout only works one what is the problem
here is the code
setTimeout(function(){
$database_time=App\time::find(1);
$hour=$database_time->hour;
$minute=$database_time->minute;
$from=date('h:i:s');
// echo $from;
if(!(Session::exists('start_time'))){
Session::put('start_time',strtotime($from));
}
$endtime=date('h:i:s',strtotime('+'.$hour.' hours'.' '.$minute.' '.'minutes',Session::get('start_time')));
$endtime;
$from=strtotime($from);
$endtime=strtotime($endtime);
$differencetime=($endtime-$from);
$display_date = date('h:i:s',$differencetime);
@endphp var value="" document.getElementById('demo').innerHTML=value;
},500);
and on the above i have
this codePlease or to participate in this conversation.