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"; }
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33, 7.1.0 - 7.1.25, 7.2.0 - 7.2.13, 7.3.0 - 7.3.1
today: 2014-12-16 (1418684400) week_first_day: 2014-12-15 (1418598000) next_week_first_day: 2014-12-22 (1419202800) date: 2014-12-13 (1418425200) This Week? NO date: 2014-12-14 (1418511600) This Week? NO date: 2014-12-15 (1418598000) This Week? YES date: 2014-12-20 (1419030000) This Week? YES date: 2014-12-21 (1419116400) This Week? YES date: 2014-12-22 (1419202800) This Week? NO date: 2014-01-01 (1388530800) This Week? NO date: 2015-02-02 (1422831600) This Week? NO

preferences:
220.95 ms | 405 KiB | 288 Q