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 ...
      • Gift Card | GraphQL methods

        Queries amGiftCardAccount(input: AmGiftCardAccountInput!) description: get gift card account information by code amGiftCardSetting description: get gift card module settings amGiftCardPreview(input: AmGiftCardPreviewInput) description: get rendered ...
      • 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 ...
      • Delivery Date Manager API

        1. Amasty\DeliveryDateManager\Api\DeliveryGuestQuoteServiceInterface - class for managing delivery data from guest carts. GET /V1/guest-carts/:cartId/quote-address-id/:quoteAddressId/get-delivery-date, method="getFromQuoteAddressId" - get delivery ...