来自数组的 PHP 平均时间 [英] PHP average time from an array

查看:36
本文介绍了来自数组的 PHP 平均时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从时间数组中计算出平均时间.

How do I work out the average time from an array of times.

我有一个看起来像这样的数组:

I have an array that looks like this :

('17:29:53','16:00:32')

我希望使用 PHP 实现 16:45:12 的结果.

And I wish to achieve the result 16:45:12 using PHP.

推荐答案

date('H:i:s', array_sum(array_map('strtotime', $array)) / count($array))

在我的手机上输入的未经测试的解决方案,应该可以工作.

Untested solution typed on my phone, should work though.

这篇关于来自数组的 PHP 平均时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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