3v4l.org

run code in 300+ PHP versions simultaneously
<?php function format_date($t, $s, $f){ return date($f,t); } $week =7*24*3600; $fix = ( intval(format_date(ceil(time()/$week)*$week,'custom', 'd')) - intval(format_date(time(),'custom','d')) )*24*3600; $sql = "select from_unixtime(ceil((created+$fix)/$week)*$week - $fix) date, count(*) from {node} where type='article' and status=1 group by date order by created desc limit 7"; print $sql;

preferences:
33.49 ms | 402 KiB | 5 Q