PHP code to get the time difference

PHP code to get time difference

Right now we are taking multiple times and getting their disparities, the following code can be utilized to get specific time distinction between multiple times.

Source Code and Output to get time distinction:

	function get_time_difference($time1, $time2)
		$time1 = strtotime($time1);
		$time2 = strtotime($time2);
		if ($time2 < $time1) 
			$time2 += 86400;
		return date("H:i", strtotime("00:00") + ($time2 - $time1));

	$timediff= get_time_difference($time1, $time2); // 12:15:29
	printf("Difference between in time : " .$timediff);
	print "</br>";


Difference between in time : 08:00

Recent Posts

error: Alert: Content is protected!!