I have a script that process raw CSV data and generate report grouped by week of the year.
Which looks something like this:
//timezone is set to Europe/London
$date = new DateTime($raw['order_date']); // example: 12/31/2012
$key = $date->format('Y W'); // 2012 01
$array[$key] = $raw['product_id'];
$key = $date->format('o W');