How to find day from specific date in PHP?

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.

Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.