How to set custom date format using Magento 2?

You can set Custom formatting of Date using Magento 2 by DateTimeFactory Class.

You just need to pass the custom format of the date in the gmtDate() function as per your requirement.

Many times, you need to set the Date format to a specific format, While you are working with third-party API you need to pass the Date as the specific format from Magento, in this situation you can use below code snippet below. Continue reading “How to set custom date format using Magento 2?”

How to override order/order_comments.phtml template in Magento 2?

You can override order_comments.phtml file using layout XML by creating a module or directly add template file to the theme level under Magento_Sales module.

order_comments.phtml file used to show the order comment in order details view page.

order_comments.phtml file is declared under the sales_order_view.xml file in Sales Module. Continue reading “How to override order/order_comments.phtml template in Magento 2?”

Check Customer isLogged in using knockout js magento 2.

You can check the customer is logged in or using knockout javascript in Magento 2 by using the Magento_Customer/js/model/customer class.

customer.js file used to check customer is logged in or not.

Customer Js file contains the method isLoggedIn() to detect customer login status. Continue reading “Check Customer isLogged in using knockout js magento 2.”