You can easily get Current Store Date Time by injecting in your class constructor in instance of
\Magento\Framework\Stdlib\DateTime\TimezoneInterface
and use that one to get the DateObject. For example:
protected $timezone; public function __construct( .... \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone, .... ) { .... $this->timezone = $timezone; .... }
And then you can use it as followed:
$date = $this->timezone->formatDate();
Magento Format
You can use the Magento format with the different params for example:
$date = $this->timezone->formatDate(null, 1);
0 = full, 1 = long , 2 = medium, 3 = short
Custom Format
or if you want to add your own format like this:
$date = $this->timezone->date(); $date = $date->format('H:i');