How to convert a week number to a month ?
For example, 162 weeks = 37,26 Month (so 37 Months if we around the number).
Have you an idea ?
that is almost trivial depenging on the accuracy you need
$days = $weeks * 7;
$months = floor($days/30);
If you need an average value:
return $numberOfWeeks * 0.229984378;
Source: http://www.google.com/search?q=1%20week%20in%20months=
(However, bear in mind that the number of weeks in a month is not constant. 1 month may contain 4 to 4.4 weeks.)
You need to have a starting date: eg. 162 weeks from ....
You can use the DateTime object for this. Create a new date, that starts on january first, then use the add method, using a DateInterval object of x weeks (new DateInterval('P' . $num . 'W');
), then format the date object using the month character.
1 month is 4.34812141
weeks.
So it would be:
$months = $weeks / 4.34812141;
If you want to round it up. You need to:
echo (int)$months;
Try this:
months = (weeks * 7) / 30