用PHP在两个MySQL的时间变量之间相减 [英] Substraction between two MySQL's time variable with PHP

查看:24
本文介绍了用PHP在两个MySQL的时间变量之间相减的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我展示我的问题:

我有两个变量包含来自 MySQL 数据库的 TIME 变量:

I have two variables that contain the TIME variable from an MySQL database:

$row[0] //it contains for instance 16:30:00
$row[1] //it contains for instance 18:00:00

如何找到从它们的减法中导出的术语?

How do I find the term that is derived from their subtraction?

因为它们已经是时间变量,所以我试图直接用这些值做减法,但我得到了四舍五入的整数值.

As they are already time variables I tried to do a subtraction directly with these values ​​but I get integer values ​​rounded down.

我尝试了现有的问题,但没有人预见到 HH: MM: SS 格式的时间.

I tried existing questions but none foresaw a time in the format HH: MM: SS.

谢谢.

推荐答案

尝试使用

$query = select TIMEDIFF(field_name, '$input_date') from tbl_name where condition

在 mysql

这篇关于用PHP在两个MySQL的时间变量之间相减的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆