Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

# Thread: Calculate monday - friday total minutes

1. ## Calculate monday - friday total minutes

Let's say I'm given a date range like so 12/01/2009 - 02/5/2010. How can I total the total minutes of only the monday - friday dates of that date range???

• It's probably a bit clunky but how about something like this:

Code:
```<?php
\$start	= mktime(0, 0, 0, 1, 12, 2009);
\$end	= mktime(0, 0, 0, 5, 2, 2010);
\$current = \$start;
\$days_count = 0;
while (\$current < \$end){
\$day_of_week = date('N', \$current);
if (\$day_of_week < 6 ){
\$days_count++;
}
\$current += 86400;
}
\$minutes_count = (\$days_count*24)*60;
echo \$minutes_count;
?>```

• Not sure it's working. I tried the below but I get 130 for the \$days_count.

<?php
\$start = mktime(0, 0, 0, 21, 2, 2010);
\$end = mktime(0, 0, 0, 27, 2, 2010);
\$current = \$start;
\$days_count = 0;
while (\$current < \$end){
\$day_of_week = date('N', \$current);
if (\$day_of_week < 6 ){
\$days_count++;
}
\$current += 86400;
}
\$minutes_count = (\$days_count*24)*60;
echo \$days_count;
?>

• You have your day and month backwards:

mktime(0, 0, 0, 21, 2, 2010)

should be

mktime(0, 0, 0, 2, 21, 2010)

•

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•