I have two columns in my table column Statestarttime contain timestamp in HH: MM (14:21) format and the Timestamp column contain timestamp in YYYY-MM-DD HH:MM:SS (2019-02-04 14:22:47) format.
I want to find out the difference beetween these columns in HH:MM (00:01)
I'm have written the below code but getting Notice: A non well formed numeric value encountered in the difference column
<?php while($row = mysqli_fetch_array($search_result)):?>
<tr>
<td align="Center"><?php echo $row['id'];?></td>
<td align="Center"><?php echo $row['EmpID'];?></td>
<td align="Center"><?php echo $row['Date'];?></td>
<td align="Center"><?php echo $row['Username'];?></td>
<td align="Center"><?php echo $row['Computername'];?></td>
<td align="Center"><?php echo $row['State'];?></td>
<td align="Center"><?php echo $row['MinutesatState'];?></td>
<td align="Center"><?php echo $row['StateStarttime'];?></td>
<td align="Center"><?php echo $row['StateEndtime'];?></td>
<td align="Center"><?php echo $row['Timestamp'];?></td>
<td align="Center"><?php echo $row['StateStarttime']-$row['Timestamp'];?></td>
</tr>
<?php endwhile;?>
You can use this, instead of the hardcoded times pass your times it will work...!
$time1 = date("h:i:s",strtotime("2019-02-04 14:22:47"));
$time2 = date("h:i:s",strtotime("14:21"));
echo date("h", strtotime($time1)-strtotime($time2));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.