S
S
Sergey Mironov2016-07-02 17:31:00
opencart
Sergey Mironov, 2016-07-02 17:31:00

How to display date difference in hours?

Hello!
$date1 = ('2016-06-05 12:24:21');
$date2 = ('2016-07-01 16:59:01');
How to calculate the difference in dates in hours and display how many hours have passed since the first date?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg, 2016-07-02
@politon

$date1 = ('2016-06-05 12:24:21');
$date2 = ('2016-07-01 16:59:01');
$hours=date_diff(new DateTime($date1), new DateTime($date2))->days*24;
echo $hours;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question