I have a table tbl_news, and I wanted to create several reports such us today, this week, this month.
I have stored time in unix timestamp at "news_adate". For this week report I am using the following query.
$first = date('Y-m-d',strtotime("monday this week"));
$last = date('Y-m-d',strtotime("sunday this week"));
$first = $first ." 00:00:01";
$last = $last ." 23:59:59";
$query = "SELECT count(nid), news_adate FROM tbl_news WHERE (news_adate between '".$first."' AND '".$last."') AND tbl_news.news_status=1 GROUP BY DATE(FROM_UNIXTIME(tbl_news.news_adate))" ;
I got the following output.
25-Oct 2015 1
27-Oct 2015 45
But actually it should be
25-Oct 2015 1
26-Oct 2015 35
27-Oct 2015 10
Don't know where is the error?