DEV Community

loading...

How to output tomorrow's date in PHP

tomox0115
I'm a geek. web developer, blog media writer and university student in Japan. I mainly use PHP(Laravel) / JS for WEB development.
Updated on ・1 min read

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

Discussion (1)

Collapse
nakato profile image
Mathieu Bernard

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

Forem Open with the Forem app