如何使用日期获取PHP中的当天名称?

Is it possible to get the name of the day in the row of numbers converted to date?

I Have Code :

$date1 = date('Y-m-01');
$Month = date('m', strtotime($date1));
$Year = date('Y', strtotime($date1));
$Maximum_Date = date('t', strtotime($date1));

for($Date = 1; $Date <= $Maximum_Date; $Date++){
  $DataDate = $Date . ' ' . $Month . ' ' . $Year . '<BR>';
  echo $DataDate;
}

Result :

1 04 2019
2 04 2019
3 04 2019
etc..

What I want is to change it to display the name of the day on that date

For Example Date in April :

Monday, 1 04 2019
Tuesday, 2 04 2019
Wednesday, 3 04 2019
etc..

[UPDATE] April 15, 2019 Refer to comments, I see documentation here and apply with mktime();

So I Update The Code :

$date1 = date('Y-m-01');
$Month = date('m', strtotime($date1));
$Year = date('Y', strtotime($date1));
$Maximum_Date = date('t', strtotime($date1));

for($Date = 1; $Date <= $Maximum_Date; $Date++){
  echo date("l, d m Y", mktime(0, 0, 0, $Month, $Date, $Year)) . '<br>';
}

And get the result :

Monday, 1 04 2019
Tuesday, 2 04 2019
Wednesday, 3 04 2019
etc..

You can simplify this a lot without converting back and forth between date and strtotime:

$year = date('Y');
$month = date('n');
$lastDay = date('t');

foreach (range(1, $lastDay) as $day) {
    echo date('D, j m Y', mktime(0, 0, 0, $month, $day, $year)), '<br>';
}

See http://php.net/mktime.

Omitting implicit default values and condensing it a bit, you can in fact boil it down to:

foreach (range(1, date('t')) as $day) {
    echo date('D, j m Y', mktime(0, 0, 0, date('n'), $day)), '<br>';
}
Mon, 1 04 2019
Tue, 2 04 2019
Wed, 3 04 2019
...
Tue, 30 04 2019

Note that this code has a minuscule potential to break, should you execute it right at the second in which one month rolls over to the next, and the date('n') and date('t') functions happen to be called "in different months". To avoid that possibility entirely, make this operation atomic:

list($year, $month, $lastDay) = explode(' ', date('Y n t'));

foreach (range(1, $lastDay) as $day) {
    echo date('D, j m Y', mktime(0, 0, 0, $month, $day, $year)), '<br>';
}

Use:

$date1 = date('Y-m-01');
$Month = date('m', strtotime($date1));
$Year = date('Y', strtotime($date1));
$Maximum_Date = date('t', strtotime($date1));

for($Date = 1; $Date <= $Maximum_Date; $Date++){
  $DataDate = date("D-m-Y",strtotime($Year."-".$Month."-".$Date));
  echo $DataDate. '<br>';;
}

The code below will print out what you need..

$date1 = date('Y-m-01');
$Maximum_Date = date('t', strtotime($date1));

for($Date = 1; $Date <= $Maximum_Date; $Date++)
{
    $thatDay = date('Y-m-'.$Date);
    $day = date('l, j', strtotime($thatDay));
    $Month = date('m', strtotime($thatDay));
    $Year = date('Y', strtotime($thatDay));

    echo $day . ' ' . $Month . ' ' . $Year . '<BR>';
}

Output:

Monday, 1 04 2019
Tuesday, 2 04 2019
Wednesday, 3 04 2019
Thursday, 4 04 2019
Friday, 5 04 2019
...
...

if you change this line

$day = date('l, j', strtotime($thatDay));

TO

$day = date('l, jS', strtotime($thatDay));

The output will be: Monday, 1st 04 2019

You should try like below.

$date1 = date('Y-m-01');
$Month = date('m', strtotime($date1));
$Year = date('Y', strtotime($date1));
$Maximum_Date = date('t', strtotime($date1));

$StartDate=$date1;
$EndDate=($Year."-".$Month."-".$Maximum_Date);
$EndDate=date('Y-m-d',strtotime($EndDate));

while(strtotime($EndDate)>=strtotime($StartDate))
{
    echo date('l, d-m-Y',strtotime($StartDate))."<br/>";
    $StartDate=date('Y-m-d', strtotime($StartDate . ' +1 day'));
}

After execute you will get result like below.

Monday, 01-04-2019
Tuesday, 02-04-2019
Wednesday, 03-04-2019
...................
...................
...................
...................
Saturday, 27-04-2019
Sunday, 28-04-2019
Monday, 29-04-2019
Tuesday, 30-04-2019

Add the following line to your loop:

    echo (new DateTime($Date. '-'. $Month .'-'. $Year))->format('l');

It creates a new DateTime object with your data & echo's the day in the format that you requested.