-3
$date = new DateTime("now", new DateTimeZone('Europe/Berlin') );
$dateUpdate = $date->format("d.m.Y H:i:s");

Hey, i need to subtract 4 Minutes from $dateUpdate. How is this possible?

Thanks

user3783243
  • 5,368
  • 5
  • 22
  • 41
ysLuk
  • 3
  • 3
  • 3
    https://stackoverflow.com/a/54878827/5947043 . Same can be found in [many other places](https://www.google.com/search?q=php+datetime+subtract+minutes) - did you search at all?? P.S. $dateUpdate is a string so you can't subtract from that directly, you have to subtract from $date and then format the result. – ADyson Aug 10 '20 at 10:11

1 Answers1

1

You can do it this way :

$date = new DateTime("now", new DateTimeZone('Europe/Berlin'));
$interval = new DateInterval("PT4M");
$date->sub($interval);
echo $date->format('Y-m-d\TH:i:s.u');

DateTime Documentation

DateInterval Documentation

Maestro
  • 865
  • 1
  • 7
  • 24