Reputation: 4709
I need to count how many times some specific days appears between two given dates. For example, I need to know how many Tuesday are between 01/03/2010 12:12:55
and 06/04/2011 16:55:20
.
So far, I can calculate the number of days (all days) between to dates with this (The dates are given in d/m/Y g:i:s
format):
<?php
function calculateDiffTime($startDate, $endDate = false)
{
$startDate = DateTime::createFromFormat('d/m/Y g:i:s', $startDate);
$endDate = DateTime::createFromFormat('d/m/Y g:i:s', $endDate);
// Calculando la diferencia entre las dos fechas.
$interval = $startDate->diff($endDate);
return $interval->format('%a days'); // Return '# days'
}
?>
What I want to do is calculate the difference between the total of days (the result of the function above) and the number of times the specific day (s) appears.
Upvotes: 1
Views: 913
Reputation: 1925
how to find number of mondays or tuesdays between two dates?
Not my response but a quick google search popped that up =P
Upvotes: 2