whenever you need to subtract a day from the whole date, such as Monday, Tuesday, etc. If you wish to find the day for a given date, such as “2023-7-13,” you can do so in two ways: first, by using strtotime(), and second, by using a DateTime object.
You can see in the example below that I provide you two different ways to determine the day from your date. Now that I have added the format “l,” it will return the entire name of the day, such as “Tuesday,” but if you only want the short name, you may alter the format to “D.”
Example 1:
<?php
$specificDate = strtotime('2023-7-13');
$day = date('l', $specificDate);
var_dump($day);
?>
// Output
string(8) "Thursday"
Example 2:
<?php
$specificDate = strtotime('2023-7-13');
$yourDate = DateTime::createFromFormat("Y-m-d", $specificDate);
var_dump($yourDate->format("l"));
?>
Output:
string(8) "Thursday"
[…] https://www.devopsconsulting.in/blog/how-can-i-use-php-to-find-day-name-from-specific-date/ […]