0

How to show current date and time list in dropdown in magento2.1.7, As I have purchased an extension for store pickup in my magento2 site.. But the date , time functionality is not working properly, so I am trying to create a new controller for getting date and time.

Any help would be appreciated

0

You need to inject in your class constructor an instance of \Magento\Framework\Stdlib\DateTime\DateTime and use that one.
Something like this:

protected $date;
public function __construct(
    ....
    \Magento\Framework\Stdlib\DateTime\DateTime $date,
    ....
) {
    ....
    $this->date = $date;
    ....
}

Then, you can use in your class this:

$date = $this->date->gmtDate();
  • I have tried this, it is not working.. – Amy Mar 7 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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