Buy best selling Linux books

<< View More Computer Tips

Added On: 17/01/16   |    Category: PHP5    |    Number of Views: 1236

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;

Search Site

Search other tutorials and tips on My Computer Tips by entering your search terms below


The Linux Foundation

Best selling Unix / Linux books
Nvidia Graphics Cards
Save 15% off .CO.UK domains at 123-Reg
Save 15% off .COM domains at 123-Reg
cPanel Hosting Plans
Xilo Web Hosting Plans