SEO friendly URL in Yii2

How to calculate difference between two dates in hour using PHP?

This is a pretty easy thing but sometimes we forget actually how we can calculate the difference between two dates! PHP Manual is a root source for this solution but its also time-consuming to search and find the procedure.

Here, I am writing as a note so, we can check in future as a reference source.

$ts1 = strtotime('03-09-2013 04:48');
$ts2 = strtotime('02-09-2013 12:12');
$diff = abs($ts1 - $ts2) / 3600;     

If you want to find the difference in day/minute/seconds then need to change something in the above code. It’s your challenge to find the accurate way..


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *