DEV Community

Ichi
Ichi

Posted on • Edited on

How to output tomorrow's date in PHP

Simply add a parameter called "+1 day" when instantiating the DataTime class.

<?php // today $today = new DateTime(); echo $today->format('Y-m-d') . PHP_EOL; // tomorrow $tomorrow = new DateTime('+1 day'); // or $tomorrow = new DateTime('tomorrow'); echo $tomorrow->format('Y-m-d'); 
Enter fullscreen mode Exit fullscreen mode

Output result
Alt Text

Top comments (1)

Collapse
 
nakato profile image
Mathieu Bernard

can use just : new DateTime('tomorrow');