datetime - How to get the total hr from start time to end time using 12 Hour Format in php -


how can total hour 2 given time "hh:mm:ss" format?

here code:

   $start = 01:00:00 pm;    $end = 02:00:00 pm; 

expected output:

   $total = 1; 

you can try this:

$start = new datetime('01:00:00 pm'); $end = new datetime('02:00:00 pm'); $diff = $start->diff($end); echo $diff->format('%h');  

you can more info: http://in1.php.net/manual/en/datetime.diff.php


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -