I am trying to measure time difference I am also learning to wright PHP..
I am saving time and date into SQL as datetime by:
$now = new DateTime();
$datenow = $now->format('Y-m-d H:i:s');
$sql = "INSERT INTO Logg ( logdate , Log , value) VALUES ( '$datenow' , 'Log', '$value' )";
I can now do a query and get:
$result = mysqli_query( $conn , $sqlq );
while($row = mysqli_fetch_array($result)) {
$myLogdate = $row['logdate'];
What I am after, is to be able to check the time between
$myLogdate
and
$now = new DateTime();
$datenow = $now->format('Y-m-d H:i:s');
I have tried:
$interval = $datenow->diff($myLogdate);
$elapsed = $interval->format('%y years %m months %a days %h hours %i minutes %s seconds');
echo $elapsed;
But I get no results....