Category: PHP5

Added: 17th of January 2016

Viewed: 1718 times

Get the day of the week for a specified date using PHP5

One thing I noted, you will get varying results if you try to get the day of the week from a specified date in PHP if you submit your date in the following format dd/mm/yy.

What you need to do is replace / with - in your date using the str_replace function, convert the date to a unix timestamp, then use the date function with l switch which will give your the proper day of the week.

Copy and paste the code below. The code will display Tuesday

$date = str_replace('/', '-', "19/01/2016");
$day = date('l', strtotime($date));
echo $day;

Other Tips & Tutorials


Convert all characters to Upper or Lower case in PHP5

Posted: 7th of October 2020

Views: 63


Get the day of the week for a specified date using PHP5

Posted: 17th of January 2016

Views: 1718


How to upload files larger than 2MB using PHP5

Posted: 14th of January 2016

Views: 1890


Preserve line breaks in PHP. nl2br function

Posted: 21st of December 2015

Views: 3361


Convert a Unix timestamp to date and time using PHP

Posted: 18th of December 2015

Views: 1984


How to validate a form using PHP5

Posted: 15th of December 2015

Views: 1005


Count the number of elements in a PHP array using the count() function

Posted: 15th of December 2015

Views: 842


Pass ampersand through query strings in URL using PHP5

Posted: 27th of November 2015

Views: 2076