简体   繁体   English

计算两个数据字段的平均值php / mysql

[英]Calculate average of two data fields php/mysql

I wonder know how to deal data format. 我不知道知道如何处理数据格式。 I have 2 columns date(starting date) * date2 (end date) *. 我有2列date(开始日期) * date2(结束日期) *。 I am not familiar with php/mysql. 我不熟悉php / mysql。

one my biggest clue is the data/data2 fields appears on this format ie. 我最大的提示之一就是data / data2字段以这种格式显示。 "1394797440". “ 1394797440”。 I am trying to build a dashboard with DB graphics of a ticket support. 我正在尝试使用票证支持的DB图形构建仪表板。 Had some features done but the data format is stressing me up. 已经完成了一些功能,但是数据格式使我感到压力。 let me know if I am right. 让我知道我是否正确。

I need to do a foreach on both fields? 我需要在两个领域都做一个foreach吗? sorry my noob question but I am totally lost :| 对不起我的菜鸟问题,但我完全迷失了:|

mostly I use this call-> $call_date = date("m/d/y",$site_calls->call_date); 我主要使用这个$call_date = date("m/d/y",$site_calls->call_date); > $call_date = date("m/d/y",$site_calls->call_date);

I will really appreciate any help. 我将非常感谢您的帮助。

The data/data2 format is most likely Unix epoch time. data / data2格式很可能是Unix时代。 It is the number of seconds since Jan 1, 1970 and can be converted to an actual date and time. 它是自1970年1月1日以来的秒数,可以转换为实际的日期和时间。

This is a UNIX epoch datetime format ie number of seconds elapsed since 1st Jan, 1970. To take average of the two dates, it is similar to any other numeric average. 这是UNIX纪元日期时间格式,即自1970年1月1日以来经过的秒数。要取两个日期的平均值,它与任何其他数值平均值相似。

$avg_date = $site_calls->call_date + (($site_calls->call_date2 - $site_calls->call_date)/2);
$call_date = date("m/d/y",$avg_date);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM