I'm attempting to debug a Timezone issue in a custom Magento module. One of the tests I would like to try is to ADD/REMOVE 1hr from whatever is output from this line of code.
I suspect ADDING 1hr could be as simple as implementing a "+1" somehow. And perhaps REMOVING 1hr might involve going back 1 Day and forward 23 hours. But honestly, I don't know what to start with this.
Line
$estimatedDeliveryDate = $this->localeDate->date()->setTime(0,0,0);
Context
class Estimator
{
private $localeDate;
public function __construct(
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
) {
$this->localeDate = $localeDate;
}
public function addEstimatedDeliveryDate(&$items)
{
$now = $this->localeDate->date();
$todayDate = $this->localeDate->date();
foreach ($items as &$item) {
$estimatedDeliveryDate = $this->localeDate->date()->setTime(0,0,0);
...
setTime(Hours,Minutes,Seconds);
, what do you want to do?setTime(Hours,Minutes,Seconds);
might work for +1 but not -1.$estimatedDeliveryDate = $this->localeDate->date('2019-03-30')->setTime(0,0,0)->format('d-m-Y H:i:s');