I have 2 dates from mysql with datetime format.
Date 1 is:
"2012/09/28 09:28:00" (column name is departure_date)
and Date 2 is:
"2012/09/29 10:48:00" (column name is return_date)
So how to get a result like this: "25 hours 20 minutes"
I don't care about the seconds.
I'm using MySQL and PHP for the programming language.
Date difference function already exists
SELECT DATEDIFF('2007-10-04 11:26:00','2007-10-04 11:50:00')
Also you can try TimeDiff
SELECT TIMEDIFF('2007-10-05 12:10:18','2007-10-05 16:14:59') AS duration;
So in your case you have the option to use these two functions like this
SELECT TIMEDIFF(departure_date,return_date) AS duration;
SELECT DATEDIFF(departure_date,return_date) AS duration;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With