How to deduct from DateTime('now') , for example, 32 hours?
2 answers
Using the modify method
$now = DateTime("NOW"); $now->modify("-32 hour"); echo $now->format("ВАШ ФОРМАТ"); |
Subtract one day 8 hours - I'm not sure that the subtraction of 32 hours will work correctly:
$date = new DateTime('now'); $date->sub(new DateInterval('P1DT8H')); Description and examples can be found here .
- oneIt is better to use DateTime :: sub () :) - xEdelweiss
|