james-r2
10/9/2015 - 5:23 AM

Calculate Time Between Dates

Calculate Time Between Dates

<?php
	if (strtotime($countdown_date) > strtotime(now)) {
		$diff = abs(strtotime($countdown_date) - strtotime(now));
		$years = floor($diff / (365*60*60*24));
		$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
		$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
		$hours   = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
	} else {
		$years = 0;
		$months = 0;
		$days = 0;
		$hours = 0;
	}
?>