I have a mysql table to store users registration . I'd like to calculate the average time between users registration time
my table is something like this,
|id|userid_id|name |time |
-----------------------------------------
|1 | 100 |xxxxxx|2016-01-25 00:27:16|
|2 | 101 |Xyyyyy|2016-01-26 05:10:04|
|3 | 102 |gggggg|2016-01-27 03:16:13|
|4 | 103 |hhhhhh|2016-01-28 00:11:33|
|5 | 104 |eeeeee|2016-01-29 00:30:16|
|6 | 105 |ssssss|2016-01-30 07:27:16|
|7 | 106 |rrrrrr|2016-01-31 01:20:12|
|8 | 107 |oooooo|2016-01-31 03:31:04|
|9 | 108 |tttttt|2016-01-31 04:55:00|
i need to know the average time between users registration mysql query . also if i use UNIXtimestamp
i need below in MySQL Query Column time to array (as timestamp). (12,16,32,65,99) Loop to calculate sum of $array: array[6]-array[5],array[5] - array[4],,array[4] - array[3] ...... etc... $average = array_sum($array) / count($array);