jeeva Posted February 21, 2007 Share Posted February 21, 2007 hi frnds, i want calculate how many time between two time? for example if i have selected 12:00 pm and 5:00 pm then answer should be 5 can i calculate like this? and how? thanks in advance jeeva Link to comment https://forums.phpfreaks.com/topic/39449-calculate-between-time/ Share on other sites More sharing options...
skali Posted February 21, 2007 Share Posted February 21, 2007 int mktime ( [int hour [, int minute [, int second [, int month [, int day [, int year [, int is_dst]]]]]]] ) this function returns tunix_timestamp. Create timestamps of the two dates and subtract them and you have another timestamp. You should divide it by 3600 to get minutes and 86400 to get hours. Link to comment https://forums.phpfreaks.com/topic/39449-calculate-between-time/#findComment-190353 Share on other sites More sharing options...
jeeva Posted February 21, 2007 Author Share Posted February 21, 2007 i did not get u... how it would help me? can u please explain........ Link to comment https://forums.phpfreaks.com/topic/39449-calculate-between-time/#findComment-190358 Share on other sites More sharing options...
skali Posted February 21, 2007 Share Posted February 21, 2007 http://www.php.net/manual/en/function.mktime.php $a = mktime(12,0); $b = mktime(17,0); $diff = $b-$a; print $diff/3600; Here $a is your starting time. and $b is your ending time Link to comment https://forums.phpfreaks.com/topic/39449-calculate-between-time/#findComment-190360 Share on other sites More sharing options...
jeeva Posted February 22, 2007 Author Share Posted February 22, 2007 can i do this in javascript? Link to comment https://forums.phpfreaks.com/topic/39449-calculate-between-time/#findComment-191095 Share on other sites More sharing options...
mmarif4u Posted February 22, 2007 Share Posted February 22, 2007 I dont know about javascript that java can or not... But code make by SKali is fine and good, Working fine... <?php $a = mktime(12,0); $b = mktime(15,0); $diff = $b-$a; print $diff/3600; ?> Link to comment https://forums.phpfreaks.com/topic/39449-calculate-between-time/#findComment-191098 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.