user

Yasen Sayed

25 Feb 2022

php difference between two times in hours

PHP & Mysql

Hello guys, anyone can help me to get the difference between the two times in PHP for example:

 "from" => "12:00:00"
 "to" => "20:00:00"

I want the difference between these times in hours.

 

Thanks.

Comments

Rakshit

25 Feb 2022

If you are using 24 hours format you don't need AM or PM annotations at all.

 

By default 00:00:00 means 12:00 AM of the day. 

In the given example, from timestamp shows time = 12:00:00, it means 12 hours passed, so your time is - 12:00 PM of the day.

 

To timestamp shows 20:00:00, it means 8:00 PM of the respective day. Max time can be 23:59:59, and after that it will be turned to 00:00:00 (12:00 AM)

 

You can add number of hours in 12:00:00 PM to count further all hours in 24 hours format if you see the time > 12:00:00.

 

Shilpa

26 Feb 2022

github

It shows you are using 24 hours format.

From date shows 12 O'clock of Afternoon

To date shows 8 O'clock of evening!

© 2024 Copyrights reserved for web-brackets.com