johnsmith153 Posted May 14, 2010 Share Posted May 14, 2010 I need a formula to calculate minutes / hours between two times: E.g. 18:00 - 23:30 would return 5 and a half hours or 330 minutes (either is fine, I just then need to multiply by an hourly wage to calculate an employees pay based on their working shift). I have created someting but it is so long winded (30 or so lines!) Is there any way to do this in a few lines or so? Link to comment https://forums.phpfreaks.com/topic/201805-formula-to-calculate-minuteshours-between-two-times/ Share on other sites More sharing options...
Mchl Posted May 14, 2010 Share Posted May 14, 2010 If you have PHP 5.3 or higher you can use date_diff Otherwise: (strtotime('23:30') - strtotime('18:00')) / 3600 Link to comment https://forums.phpfreaks.com/topic/201805-formula-to-calculate-minuteshours-between-two-times/#findComment-1058549 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.