I am working on a task to modify Date Range on Dashboard chart. Data chart will display on custom date range selection (Today/Yesterday/This Week/Last Week/This Month/Last Month).
I have extend the module from core (\app\code\core\Mage\Reports\Model\Resource\Order\Collection.php) to local (\app\code\local\Andi\Dashboard\Model\Reports\Resource\Order\Collection.php). I make changes to the getDateRange function.
case '2d': $dateEnd = Mage::app()->getLocale()->date(); $dateEnd->addHour(1); $dateStart = clone $dateEnd; $dateStart->subDay(2); break;
for yesterday data.
2d means yesterday.
The condition is that the data shown today is the data of today's date only and does not include data from yesterday. Data shown yesterday was a day of data without the data the day before yesterday and today. So also with the data of the Week, Last Week, This Month, Last Month, This Year and Last Year.
I have debug it and get the following data:
$dateEnd = Mage::app()->getLocale()->date(); is Feb 12, 2015 7:56:15 PM $dateEnd->addHour(1); is Feb 12, 2015 8:56:50 PM $dateStart->subDay(2); is Feb 10, 2015 8:57:34 PM
How do I make by using addHour, subHour, addDay, subDay, addWeek, subWeek, addMonth, subMonth, addYear and subYear. Or can use this?
$current_time = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time())); $yesterday = date("Y-m-d", Mage::getModel('core/date')->timestamp(time()-(60*60*24)));