Jump to content
ludah

Difference between only time

Recommended Posts

Please Can someone help

me on this

 

Am creating a timetable system and i want to check only the time difference

 

Am collect a time only from the html form thus

$startTime = 13:30:00

$endTime = 14:00:00


How can i find the deference between this time from the html in php.

Thanks

Share this post


Link to post
Share on other sites

Use DateTime class.

$startTime = '13:30:00';
$endTime = '14:00:00';

$dt1 = new DateTime($startTime);
$dt2 = new DateTime($endTime);
$diff = $dt1->diff($dt2);
echo $diff->format('%h:%I'); //--> 0:30

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.