Home php How to find day from specific date in PHP?

How to find day from specific date in PHP?

by Shahriar Sagor

Today now in this blog i will show you how to find day from specific date in php application. Whenever we need to get day as like as Monday, Tuesday etc from the full date. Here i mean we have a any specific date as like “2021-06-04” and we want to get day then we can do in both way first one is by using strtotime() and second one is by using DateTime object.

Now on following example we can see i will give you both way to get day from your date. Now i will added format ‘l’ so it will return full name of day like “Tuesday”, but if we want to get short name of day then we need to change format like “D”.

// Using strtotime()
$specificDate = strtotime('2016-2-3');
$specificDate = date('l', $specificDate);
// Using DateTime Object
$yourDate = "2011-12-2";
$yourDate = DateTime::createFromFormat("Y-m-d", $yourDate);

Read Also : How to copy one table data into another table in Mysql Query?

Thanks for read. I hope it help you. For more you can follow us on facebook.


You may also like