- time: documentation ( source)
- ceil: documentation ( source)
- date: documentation ( source)
<?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;