toprashantjha Posted December 27, 2011 Share Posted December 27, 2011 How to calculate number of bussiness hours beetween to given dates? For example - I want to get difference hours beetween '2011-12-25 24:00:00' and '2011-12-28 10:00:00' and the result should only consider the time beetween 9:00 to 17:00. Please help.. Quote Link to comment https://forums.phpfreaks.com/topic/253895-calculate-time-difference/ Share on other sites More sharing options...
fenway Posted December 27, 2011 Share Posted December 27, 2011 In general, you can use TIMEDIFF() and then TIME_TO_SEC(). But if you want further restrictions, you'll need to break up each datetime into business and non-business parts first. Quote Link to comment https://forums.phpfreaks.com/topic/253895-calculate-time-difference/#findComment-1301595 Share on other sites More sharing options...
toprashantjha Posted December 27, 2011 Author Share Posted December 27, 2011 Could you please suggest me how to break up datetime into bussiness/non bussiness hours? Quote Link to comment https://forums.phpfreaks.com/topic/253895-calculate-time-difference/#findComment-1301596 Share on other sites More sharing options...
fenway Posted December 29, 2011 Share Posted December 29, 2011 That's very complex -- you'd have to break up each period into days, and then compare each hour against "valid" hours. Quote Link to comment https://forums.phpfreaks.com/topic/253895-calculate-time-difference/#findComment-1302195 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.