Some useful code related to date in Magento :
1/ Get the current time :
1 2 3 |
$currentTime = date("d.m.Y", Mage::getModel('core/date')->timestamp(time())); echo $currentTime; |
2/Get the first day of current month:
1 2 3 |
$firstDayOfCurrentMonth = date("01.m.Y", Mage::getModel('core/date')->timestamp(time())); echo $firstDayOfCurrentMonth; |
3/Get the last day of current month :
1 2 3 |
$lastDayOfCurrentMonth = date("t.m.Y", Mage::getModel('core/date')->timestamp(time())); echo $lastDayOfCurrentMonth; |
4/Get the first day of previous month :
1 2 3 |
$firstDayOfPrevMonth = date("01.m.Y", Mage::getModel('core/date')->timestamp(strtotime('first day of previous month'))); echo $firstDayOfPrevMonth; |
5/Get the last day of previous month :
1 2 3 |
$lastDayOfPrevMonth = date("t.m.Y", Mage::getModel('core/date')->timestamp(strtotime('first day of previous month'))); echo $lastDayOfPrevMonth; |
POST HASN'T TAG.