Q:

Get weekday by date

I need to get day of week by given date, but don't know how.
It's my homework(actually question wizard testing) and I don't know where should I start
function weekDay($date) {
  return 'Friday'; 
}

I expect to get actual weekday, but always receive Friday.

A:

Try like this way,
<?php
$date = DateTime::createFromFormat('Y-m-d', '2018-06-21');
echo $date->format('l'); # l for full week day name
?>

Ref.: http://php.net/manual/en/datetime.createfromformat.php
Demo: https://eval.in/1025956

