How to change the format of the delivery date?

How to change the format of the delivery date?

Starting from version 2.11.0, the delivery date format on the frontend is displayed according to the selected store locale in Magento configurations: Stores → Configuration → General → General → Locale Options → Locale.





For lower versions, the format of the delivery date is MM/DD/YYYY by default. It can't be changed in the extension settings, but it's easily done through the code changes. For that, please follow the steps below.

Step 1. Open the GiftCard/view/frontend/web/template/datepicker.html file, scroll down to line 22 (starting with data-bind=), and replace the placeholder with the desired one:



The result should be as follows: 


This doesn't change the date format yet — only the "example" your customers see in the date picker widget


Step 2. Open the GiftCard/view/frontend/web/js/datepicker.js file, scroll down to line 38 (changeYear: true), and add a new line after it. Paste the following, comma included:

dateFormat: 'dd/mm/yyyy',



Now, the date will show in the desired format on the storefront: 



Additionally, you can change the date display in the mini-cart and checkout, if the Show Gift Card Options in Mini Cart And Checkout setting is enabled. For that, open the GiftCard/Model/GiftCard/Product/Type/GiftCard.php file and find lines 276-277



These lines are to be replaced with the code snippet below: 

$chosenDate = \DateTime::createFromFormat(
          'd/m/Y',
          $buyRequest->getData($field),
          new \DateTimeZone($buyRequest->getData(GiftCardOptionInterface::DELIVERY_TIMEZONE))
  )->getTimestamp();



The date will then be recognized correctly in the product details in the shopping cart, preventing any discrepancies in case of a date shift due to the timezone difference.

      • Related Articles

      • How to choose time/date of sending a gift card via email?

        The extension allows customers to select only the date of certificate delivery. For greater delivery accuracy, customers will need to specify the recipient's timezone. The email is sent with the execution of the first cron job on the selected date. ...
      • How does printed card work in the Gift Card extension?

        By default, the Gift Card extension offers administrators the flexibility to choose the type of gift card during its creation: virtual, printed (physical), or combined. A virtual gift card functions as an email-sent code, resembling the format of ...
      • Is it possible to rearrange and stylize elements on the gift card image?

        Starting from version 2.7.0, the Gift Card extension provides UI for editing and rearranging elements (expiry date, balance, etc.) on the gift card image right from the admin panel. To do so, add a new image in Gift Card → Images → Add New or open ...
      • Why does shipping/tax stay the same after applying a gift card to the order?

        In its essence, a gift card is different from a discount coupon. A discount is applied to the product(s) in the order, changing their final price. Thus, Magento recalculates tax and shipping rates to correspond with the changed final price of the ...
      • How to activate the gift card account?

        The gift card account is created automatically when the order is invoiced and paid. If the order has the Complete status, but the code of the gift card is not activated and can't be applied, please contact our team.