I am getting date by injecting this class in constructor \Magento\Framework\Stdlib\DateTime\DateTime
as:
protected $date;
public function __construct(
....
\Magento\Framework\Stdlib\DateTime\DateTime $date,
....
) {
....
$this->date = $date;
....
}
and then, in class this:
$date = $this->date->gmtDate();
But how can I add or subtract month to this date for Expiration feature ?
Best Answer
You should try :
$date = $this->date->gmtDate('Y-m-d\TH:i:s\Z', strtotime('+1 month'));