3v4l.org

run code in 300+ PHP versions simultaneously
<?php function weekCounter($startDate,$endDate=null){ //use today as endDate if no date was supplied $endDate = $endDate? : date('Y-m-d'); //calculate # of full weeks between dates $secsPerWeek = 60 * 60 * 24 * 7; $fullWeeks = floor((strtotime($endDate) - strtotime($startDate))/$secsPerWeek); $fullMonths = floor($fullWeeks/4); $weeksRemainder = $fullWeeks % 4; // weeks that don't fit in a month //increment from 0-base to 1-base, so first week is Week 1. Same with months $fullMonths++; $weeksRemainder++; return [$fullMonths,$weeksRemainder]; } $startDate = '2016-06-27'; //put function results in $months and $weeks variables list($months,$weeks) = weekCounter($startDate); //you can use the variables however you want echo "Month: $months, Week: $weeks";
Output for git.master, git.master_jit, rfc.property-hooks
Month: 63, Week: 3

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
36.81 ms | 405 KiB | 5 Q