3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dates = array('2014-12-13','2014-12-14','2014-12-15','2014-12-20','2014-12-21','2014-12-22','2014-01-01','2015-02-02'); $first_day_of_week = 1; $day_of_week = date('w'); $sow_offset = ($day_of_week - $first_day_of_week + 7)%7 * 24*60*60; $week_first_day = date('Y-m-d', time()-$sow_offset); $nsow_offset = ((6 - $day_of_week + $first_day_of_week + 7)%7 +1) * 24*60*60; $next_week_first_day = date('Y-m-d', time()+$nsow_offset); echo "\ntoday: ".date("Y-m-d")." (".strtotime(date("Y-m-d")).")"; echo "\nweek_first_day: ".$week_first_day." (".strtotime($week_first_day).")"; echo "\nnext_week_first_day: ".$next_week_first_day." (".strtotime($next_week_first_day).")"; echo "\n\n"; foreach ($dates as $date) { echo "\ndate: ".$date." (".strtotime($date).")"; echo "\nThis Week? ".((strtotime($week_first_day) <= strtotime($date) && strtotime($date) < strtotime($next_week_first_day)) ? "YES" : "NO"); echo "\n\n"; }

preferences:
37.14 ms | 402 KiB | 5 Q