How to get Current GMT date time in Magento 2?

You can get GMT Timezone in Magento by below code snippet,
Magento gives GMT timezone based on below function, Magento comes with DateTime php class, Magento\Framework\Stdlib\DateTime\DateTime is used for Forms GMT date.

Call from template file or php file by below way,

$dateModel = $this->dateTimeFactory->create();
echo $dateModel->gmtDate();

First Parameter if gmtDate() is optional $format = null.
Default Format is Y-m-d H:i:s, You can add your time zone for convert normal timezone to GMT Timezone.

Leave a Reply

Your email address will not be published. Required fields are marked *