How to facilitate access to today, yesterday, one day before，two day before 's data？
<pre><code>$active_count1_end=date('Y-m-d');
$active_count1_end.=" 23:59:59";
$active_count1_start=date('Y-m-d');
$active_count1_start.=" 00:00:00";
$count10=$today-&gt;query("select  count(*) as count1 from talk where time1 between '". $active_count1_start."' and '".$active_count1_end."'");
$count11=$today-&gt;query("select  count(*) as count2 from reply where time2 between '". $active_count1_start."' and '".$active_count1_end."'");
$count1=$count10[0][count1]+$count11[0][count2];

$active_count2_end=strtotime($active_count1_end)-24*3600;
$active_count2_end=date('Y-m-d',$active_count2_end);
$active_count2_end.=" 23:59:59";
$active_count2_start=strtotime($active_count1_end)-24*3600;
$active_count2_start=date('Y-m-d',$active_count2_start);
$active_count2_start.=" 00:00:00";
$count20=$today-&gt;query("select  count(*) as count1 from talk where time1 between '". $active_count2_start."' and '".$active_count2_end."'");
$count21=$today-&gt;query("select  count(*) as count2 from reply where time2 between '". $active_count2_start."' and '".$active_count2_end."'");
$count2=$count20[0][count1]+$count21[0][count2];

$active_count3_end=strtotime($active_count2_end)-24*3600;
$active_count3_end=date('Y-m-d',$active_count3_end);
$active_count3_end.=" 23:59:59";
$active_count3_start=strtotime($active_count2_end)-24*3600;
$active_count3_start=date('Y-m-d',$active_count3_start);
$active_count3_start.=" 00:00:00";
$count30=$today-&gt;query("select  count(*) as count1 from talk where time1 between '". $active_count3_start."' and '".$active_count3_end."'");
$count31=$today-&gt;query("select  count(*) as count2 from reply where time2 between '". $active_count3_start."' and '".$active_count3_end."'");
$count3=$count30[0][count1]+$count31[0][count2];

$active_count4_end=strtotime($active_count3_end)-24*3600;
$active_count4_end=date('Y-m-d',$active_count4_end);
$active_count4_end.=" 23:59:59";
$active_count4_start=strtotime($active_count3_end)-24*3600;
$active_count4_start=date('Y-m-d',$active_count4_start);
$active_count4_start.=" 00:00:00";
$count40=$today-&gt;query("select  count(*) as count1 from talk where time1 between '". $active_count4_start."' and '".$active_count4_end."'");
$count41=$today-&gt;query("select  count(*) as count2 from reply where time2 between '". $active_count4_start."' and '".$active_count4_end."'");
$count4=$count40[0][count1]+$count41[0][count2];
</code></pre>

<p>The code is use to make a forum,
<code>$count1</code> is today's data,
<code>$count2</code> is yesterday's data,
<code>$count3</code> ...,
<code>$count4</code> ...
Of course，the code has no errors, but it doesn't look good.
Do you have some Optimization Methods for the code?</p>
