I display the expected delivery date on our products, using the following line:

<?php if (in_array($_product->getData('delivery_eta'), array('2010-01-01 00:00:00','12-31-2099'))):?>

I want to expand this, by adding another if element that checks the currect date and if it "delivery_eta" is lower than today.

How can I achieve that?

1 Answer 1


Sounds like you need something like:

$productEta = $_product->getData('delivery_eta');
if(strtotime($productEta) < strtotime(date("d-m-Y"))) {
   //Your code for if eta is less than today
  • That does not seem to work. When I check the value of date that you suggest. I get the following value 1480377600
    – JGeer
    Commented Nov 29, 2016 at 9:51
  • yes that is the timestamp, I'm assuming getData('delivery_eta') is a date value like 20/11/2016 so we need a timestamp value to compare to todays timestamp. So we do strtotime to create the comparable timestamp.
    – DanCarlyon
    Commented Nov 29, 2016 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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