spice
spice

Reputation: 1510

Get the day number for tomorrow PHP

To get the numerical representation of the 7 day week you do this :

echo date('N'); // 2 (Tuesday)

Is there a built in function to get tomorrow's numerical day?

I know how I could do it programatically, but I was wondering if there was a function to do this?

Upvotes: 1

Views: 853

Answers (2)

Obsidian Age
Obsidian Age

Reputation: 42384

You can use DateTime() and modify() to +1 day:

$datetime = new DateTime();
$datetime->modify('+1 day');
echo $datetime->format('N');

Or alternatively just set the modification in DateTime() directly:

$datetime = new DateTime('+1 day');
echo $datetime->format('N');

Other relative date statements are available as well, such as tomorrow. These are detailed on the Supported Date and Time Formats: Relative Formats manual page.

Upvotes: 5

Nick
Nick

Reputation: 147266

You could use date with strtotime, which can take a string expressing a relative date e.g.

echo date('N', strtotime('tomorrow'));

Upvotes: 3

Related Questions