PHP-时间减去时间到分钟 [英] PHP - time minus time to minutes

查看:88
本文介绍了PHP-时间减去时间到分钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在php中,我有两次-11:00:00和12:45:00.我想在几分钟之内得到它们之间的差,在本例中为105分钟.最好的方法是什么?

In php i have two times - 11:00:00 and 12:45:00. I want to get the difference between them in minutes, in this case 105 minutes. Whats the best way that can be done?

谢谢!

推荐答案

在这里:

( strtotime('12:45:00') - strtotime('11:00:00') ) / 60

strtotime() 是一个非常有用的功能.它返回 Unix时间戳,以显示各种时间和日期.因此,如果您将两个时间戳记相减,然后减去它们,那么您的差异将以秒为单位.除以60得到分钟.

strtotime() is a very useful function. It returns the Unix timestamp for a wide variety of times and dates. So, if you take the two timestamps, and subtract them, then you have the difference in seconds. Divide by 60 to get the minutes.

这篇关于PHP-时间减去时间到分钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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