How to convert current timezone date and time to gmtdate and time ?

Here I am adding some hours for todays date and wants to convert in gmtdate to filter order colleciton


echo $toDay = $this->timezone->date()->format('Y-m-d H:i');

  $fromTime = strtotime($toDay);
  $toTime = $fromTime + 3600;

This below code gives current timezone time by adding one hour but I want to convert in gmt date and time

echo date('Y-m-d h:i', $toTime);
  • did you find any solution for this problem Commented May 24 at 9:06

1 Answer 1


The Magento\Framework\Stdlib\DateTime class has a gmtDate function which can be used in your code since the $this->timezone->date() function will return a DateTime object:

echo $this->timezone->date()->gmtDate('Y-m-d h:i');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.