jeremyFreeAgent / Bitter

Bitter is a simple but powerful analytics library
http://bitter.free-agent.fr
MIT License
129 stars 18 forks source link

Add a class to get count for an Event by month or week or day #13

Open jeremyFreeAgent opened 11 years ago

jeremyFreeAgent commented 11 years ago

Something like:

$lastYear = new Year(new DateTime('last year'));
$stats = $bitter->getStats('action', $lastYear, 'month');
$max = $stats->getMax();
foreach ($stats as $stat) {
    echo $stat->getDate() . ' - ' . $stat->getCount() . "\n";
}
stephpy commented 11 years ago

$lastyear = new \DatePeriod(new \DateTime('......'), new \DateTime('P1M'), new \DateTime('......'));

$bitter->getStats('action', $datePeriod);

We have to override DatePeriod to get end date and to add some options.