I would like to find out the magento2 equivalent of the below code from magento 1
Mage::app()->getLocale()->storeTimeStamp()
Can anyone assist me?
I would like to find out the magento2 equivalent of the below code from magento 1
Mage::app()->getLocale()->storeTimeStamp()
Can anyone assist me?
Something like \Magento\Framework\Stdlib\DateTime\TimezoneInterface
?
For example:
protected $_timezone;
public function __construct(
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone,
) {
$this->_timezone = $timezone;
}
Then you can use:
$date = $this->timezone->formatDate();
Alternatively, \Magento\Framework\Stdlib\DateTime\DateTime::gmtDate();
might give you what you want.
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$dateTime = $objectManager->get("Magento\Framework\Stdlib\DateTime\DateTime");
var_dump($dateTime->gmtDate());
var_dump($dateTime->gmtTimestamp());
?>