0

This question isn't about how to change the Magento data/time format.

I use a third-party shipping platform that stores delivery date as part of the order and the delivery date is order specific. It is held in the DB against the order.

Their extension exposes that data as a variable - {{var deliveryDate}} for inclusion in transactional emails and that bit works ok.

The problem I'm having is they store the date as UTC YYYY/MM/DD in the database and it's confusing for UK customers to read dates in that order.

My question is does anyone know if there is there a way in PHTML that enables me to change the display of that variable into something more UK friendly?

I'm not trying to change the display date in the frontend, I know how to do that, this is changing the format of a specific variable from a 3rd party extension. Would appreciate that help everyone.

0

Add this code in your phtml or where you want to convert the date.

$currentdate = "2019/07/19";
$newDate =  date("d-m-Y", strtotime($currentdate) );
echo $newDate; //19-07-2019

Hope, it will be helpful.

  • Thank you for the reply. The variable delivery date isn't a constant and varies from order to order. They expose that to emails as {{var deliveryDate}} and I don't know how to modify your code to take that variable and change it Woudld appreciate the help. – wjpbill Jul 19 at 12:46
  • I know it is not constant, I just gave you an example that how to change the date format, you need to apply this code where you get the delivery date variable in your phtml, modify it and then send it to the email template. – ASQ Jul 22 at 4:23
  • Hi Thanks for the reply, I do appreciate the help. I'm a little stuck on how I add {{var deliveryDate}} in that code example you gave me. $currentdate = {{var deliveryDate}}; $newDate = date("d-m-Y", strtotime($currentdate) ); echo $newDate; //19-07-2019 doesn't work and I'm not that advanced a developer. – wjpbill Jul 23 at 7:59

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.