Skip to content
Advertisement

Finding Average Time for Created At and Updated At – PHP & MYSQL

I have a table to which has created_at and updated_at. Created at is when the client purchased the order and the updated_at field is updated when the order is approved like below.

I want to get the average time it took my admin to approve the items in the table below. This is my sql

JavaScript

My results is 8025356.2742000870. Am I on the right path and how do I convert the average time to hours like 2hrs 15mins

Table

JavaScript

Advertisement

Answer

Yes, you can find the answer with using strtotime() $time = date('H :i', strtotime($res)); This is what I have tried,

JavaScript

Then you can use explode method to discribe as follow,

JavaScript

It’s work fine, and think It will help you.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement