Ben Gordon
Ben Gordon

Reputation: 437

Count days minus weekends

I have a form that allows a user to enter the length of an event using 2 jquery date pickers which are then stored in a database using date.

I then return the number of days the event lasts for but I need to exclude weekends.

For example if an event lasts from Mon - Mon the result returned would be 6.

Here is how I'm currently returning the number of days from 2 date ranges:

<?=(($currentCourseDates)?ceil((strtotime($currentCourseDates[0]['enddate']." 00:00:00") - strtotime($currentCourseDates[0]['startdate']." 00:00:00")) / 86400)+1:0)?>

Upvotes: 0

Views: 2895

Answers (1)

RossC
RossC

Reputation: 1230

There are plenty of solutions here: Calculate business days for php, using arrays, recursion, numbering

Upvotes: 1

Related Questions