ItSolutionStuff.com

How to Find Day Name from Specific Date in PHP?

By Hardik Savani • May 14, 2024
PHP

Whenever you need to det day like Monday, Tuesday etc from full date. i mean you have any specific date like "2015-10-10" and you want to get day then you can do in both way first using strtotime() and second using DateTime object.

In Following example you can see i give you both way to get day from your date. now i added format 'l' so it will return full name of day like "Tuesday", but if you want to get short name of day then you can change format like "D".

Example 1:

index.php

<?php

$specificDate = strtotime('2023-01-28');

$day = date('l', $specificDate);

var_dump($day);

?>

Output:

string(8) "Saturday"

Example 2:

index.php

<?php

$specificDate = strtotime('2023-01-28');

$yourDate = DateTime::createFromFormat("Y-m-d", $specificDate);

var_dump($yourDate->format("l"));

?>

Output:

string(8) "Saturday"

I hope it can help you...

Tags: PHP
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Check Current PHP Version in Ubuntu?

Read Now →

How to Remove Numbers from String in PHP?

Read Now →

How to Convert Camel Case to Snake Case in PHP?

Read Now →

PHP nl2br() Function Example Tutorial

Read Now →

How to Add Text Watermark to Image in PHP?

Read Now →

How to Remove First Element from Array in PHP?

Read Now →

How to Check if String Contains Specific Word in Laravel?

Read Now →

How to Get Specific Key Value from Multidimensional Array PHP?

Read Now →

How to Get File Name without Extension in PHP?

Read Now →

How to Get a Current Page URL in PHP?

Read Now →

How to Convert Array Values to Lowercase in PHP?

Read Now →

How to Count Number of Files in a Directory in PHP?

Read Now →

How to Remove Null Values from Array in PHP?

Read Now →