3v4l.org

run code in 300+ PHP versions simultaneously
<?php $firstOfMonth = strtotime(date("Y-m-01", strtotime("2017-07-17"))); //Apply above formula. echo intval(date("W", $date)) - intval(date("W", $firstOfMonth)) + 1;

preferences:
33.36 ms | 402 KiB | 5 Q