Hi I am facing problem for getting difference between hours and miuntes
I have two variables
$one=9:30 am; $two=6:30 pm;
How to get difference in Hours and minutes
Hi,
use the DateTime library, in particular look at the diff()
method. For example:
<?php
$one = '09:30AM';
$two = '06:30PM';
$dtime_1 = new Datetime($one);
$dtime_2 = new Datetime($two);
$diff = $dtime_1->diff($dtime_2);
echo $diff->format('%H:%I');
Will print 09:00
. More info here:
Excellent its working
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.