How to get the day of the week in DateTime ?

I can’t find the way to get the day of the week from a DateTime. It’s can be number or string, both are ok.

$today = new DateTime("today");
echo $ today->//whatever to get Friday, Monday or 5, 0

How to get the day of the week in DateTime ?

Edit: I am using DateTime, not date.

1 Answers

0
Ryan Nghiem On Best Solutions

You can use format() function

$today->format('l') //Sunday through Saturday
$today->format('w') //0 (for Sunday) through 6 (for Saturday)