Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Perl

Idiom #184 Tomorrow

Assign to t a string representing the day, month and year of the day after the current date.

use DateTime;
$t = DateTime->today->add(days => 1)->ymd;

Use object chaining to get today's date, add 1, and convert to a string.
use DateTime qw();
my $dt = DateTime->today;
$dt->add(days => 1);
my $t = $dt->strftime('%F');
var t = DateTime.Today.AddDays(1).ToShortDateString();

You can start with DateTime.Today or with DateTime.Now

Today will include the current date, whereas Now will also include the time of day.

if you add 1 day to now, you will get a time of day tomorrow.
e.g. 9:15 AM today plus 1 day = 9:15 AM tomorrow

New implementation...
< >
steenslag