Introduction #

When you have datetime column and you want to group those date into week of year, month, quarter or year, TimeBucket process will come into play. This process will collect the datetime and put them into bucket of your choice whether year or month or other.

TimeBucket is great when used with Group or Pivot process. The datetime data after categorized by TimeBucket can be aggregated by Group or Pivot process.

Preset time bucket #

dateCategorize datetime into date
monthCategorize datetime into month
quarterCategorize dateime into quarter
weekCategorize datetime into week number
yearCategorize datetime into year
hourofdayCategorize time into hour of day, outout value's range is [0-23]
dayofweekCategorize datetime into day of week, output value's range is [0-6] [Monday - Sunday]
dayofmonthCategorize datetime into day of month, output value's range is [1-31]
monthofyearCategorize datetime into month of year, output value's range is [1-12] [January - December]

Example #

use \koolreport\processes\TimeBucket;
use \koolreport\processes\Group;
class MyReport extends \koolreport\KoolReport
    public function setup()
        ->pipe(new TimeBucket(array(
        ->pipe(new Group(array(

Code explanation:

  1. In above example, the created_time is chunked by quarter and then be grouped. At the end, we will get a table with Quarter and the sum of amount for particular quarter.

Get started with KoolReport

KoolReport will help you to construct good php data report by gathering your data from multiple sources, transforming them into valuable insights, and finally visualizing them in stunning charts and graphs.