3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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;
based on aARmX
Output for 7.2.0
Warning: Use of undefined constant t - assumed 't' (this will throw an Error in a future version of PHP) in /in/bFDqE on line 2 Warning: date() expects parameter 2 to be integer, string given in /in/bFDqE on line 2 Warning: Use of undefined constant t - assumed 't' (this will throw an Error in a future version of PHP) in /in/bFDqE on line 2 Warning: date() expects parameter 2 to be integer, string given in /in/bFDqE on line 2 select from_unixtime(ceil((created+0)/604800)*604800 - 0) date, count(*) from {node} where type='article' and status=1 group by date order by created desc limit 7
Output for 7.0.0 - 7.1.10
Notice: Use of undefined constant t - assumed 't' in /in/bFDqE on line 2 Warning: date() expects parameter 2 to be integer, string given in /in/bFDqE on line 2 Notice: Use of undefined constant t - assumed 't' in /in/bFDqE on line 2 Warning: date() expects parameter 2 to be integer, string given in /in/bFDqE on line 2 select from_unixtime(ceil((created+0)/604800)*604800 - 0) date, count(*) from {node} where type='article' and status=1 group by date order by created desc limit 7
Output for 5.4.0 - 5.6.28
Notice: Use of undefined constant t - assumed 't' in /in/bFDqE on line 2 Warning: date() expects parameter 2 to be long, string given in /in/bFDqE on line 2 Notice: Use of undefined constant t - assumed 't' in /in/bFDqE on line 2 Warning: date() expects parameter 2 to be long, string given in /in/bFDqE on line 2 select from_unixtime(ceil((created+0)/604800)*604800 - 0) date, count(*) from {node} where type='article' and status=1 group by date order by created desc limit 7