Weeks difference between 2 dates

Hi Guys

I want to calculate the number of weeks between 2 dates. I have the code to get the number of days and divide by 7 and roundup but this is not the solution I need.

Here is an example

Say the date is 12.09.2012 and this is a Wednesday and the end date is the 24.12.2012 and this is a Thursday then the count I need is the number of weeks and the 2 partial weeks count as 2 weeks also.

Does anyone have a solution for this?

Many thanks,

Regards

Fergal.

hi check the below code. [php] $datefrom = '01.02.2012'; // Starting Date $dateto = '29.02.2012';// End date $diff = strtotime($dateto, 0) - strtotime($datefrom, 0); echo 'Between '.$datefrom.' to '.$dateto.' date has= '.floor($diff / 604800).' Weeks'; [/php] I hope this will helpful for you. Reply your feedback.. ~~SR~~
Sponsor our Newsletter | Privacy Policy | Terms of Service