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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With