0

I’m trying to compare the current date timestamp with product special price end date. to get current date I use :

$currentDate = Mage::getModel('core/date')->timestamp(time());

and for specialToDate :

$promoEndDate = strtotime($product->getSpecialToDate() );

the problem is that magento changes the date format when someone changes the admin locale and then strtotime for promo price returns null. does anyone have an idea how can I retrieve getSpecialToDate() and convert it to timestamp ?

Thank you :))

1

try to this way

$date = Mage::app()->getLocale()->date($product->getSpecialToDate(),
        Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
        null, false
        );
$promoEndDate = strtotime($date);

For Date Format :

const DATETIME_INTERNAL_FORMAT = 'yyyy-MM-dd HH:mm:ss';
const DATE_INTERNAL_FORMAT = 'yyyy-MM-dd';
const DATETIME_PHP_FORMAT       = 'Y-m-d H:i:s';
const DATE_PHP_FORMAT           = 'Y-m-d';
|improve this answer|||||
  • Hi! thank you for your reply, I tried your solution, the first part works fine. but second part sometime doesn't convert date correctly for example : if we have this date format 11/02/2020: echo date('d m Y', 1604275200).date("F", 1604275200); it echos : 11 02 2020February and for this format: /11/2020 echo date('d m Y', 1581379200).date("F", 1581379200); 02 11 2020November – Anass Hl Feb 21 at 8:45
  • please check updated answer. still face issue try to use php date function for change date format – chandresh chauhan Feb 21 at 10:46
  • Thank you so much it Works :))) – Anass Hl Feb 21 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.