PHP将mysql查询字符串转换为mm:ss时间格式

PHP将mysql查询字符串转换为mm:ss时间格式,php,mysql,datetime,time,formatting,Php,Mysql,Datetime,Time,Formatting,我想知道如何得到两个mysql varchar字符串之间的差异,它们的格式是mm:ss,其中m代表分钟,s代表秒。比如说 $a = 13:20; $b = 13:00; 我应该使用什么功能来 $a - $b = 00:20 ? $a = strtotime('13:20'); $b = strtotime('13:00'); echo "The time difference between 13:20 and 13:00 is : " . ($a - $b); Gives me

我想知道如何得到两个mysql varchar字符串之间的差异,它们的格式是mm:ss,其中m代表分钟,s代表秒。比如说

$a = 13:20;
$b = 13:00;
我应该使用什么功能来

 $a - $b =  00:20 ?

$a = strtotime('13:20');
$b = strtotime('13:00');
echo "The time difference between 13:20 and 13:00 is : "  . ($a - $b);

Gives me 
The time difference between 13:20 and 13:00 is : 1200

Kindly take note of my original format. mm:ss
使用
strotime()

试试这个

$time1 = explode(':', '13:20');
$time2 = explode(':', '13:00');

$a = 00 . ':' . $time1[0] . ':' . $time1[1];
$b = 00 . ':' . $time2[0] . ':' . $time2[1];

echo "The time difference between 13:20 and 13:00 is : "  . (strtotime($a) - strtotime($b));

$a=标准时间('13:20')$b=标准时间('13:00');echo“13:20和13:00之间的时差为:”。($a-$b);给我13:20和13:00之间的时差是:1200请注意我的原始格式。mm:ss
00:13:20
00:13:00
因为如果你使用
13:20
13:00
它读作
13:20:00
13:00:00
它返回1200…好的,谢谢你会尝试一下它的工作原理,现在我如何在mysql中使用它来查询数据库?Thankschange
explode(':','13:20')
with
explode(':',$row['time'])
您提供的是小时格式的……我想是这样,但不幸的是,在数据库中就是这样找到的。我该如何解决这个问题。谢谢你告诉我它是如何存储在你的数据库中的。我有一个列条目,比如18:30、66:15、17:40、16:59、90:48等等,都是以mm:ss的形式出现的。谢谢,减去秒,然后。