Php get day name from date
Show
Home » PHP: Get Day Name From Date Last updated on June 5, 2021 by In this tutorial, we will learn how to get the day name from the date in PHP. The PHP provides very useful functions and classes by using it we can easily format
the date. Let’s just dive into it and explore it. Get Day Name From Date In PHPPHP provides the date() method which is used to format the date as we want. We can also get the day name from the date. Also, this function is useful to change any kind of date format. Let’s see simple examples. Example 1: Extract Day Name From Static DateIn this example, we have used the createFromFormat() function which helps us to provide exact conversion from the specific date format else it might interpret the wrong date format and gives us the wrong output. It is always advisable to use createFromFormat() function while dealing with the static dates or if you changed the default date format. format('l'); // echo $datetime->format('D'); // Output: Sat Output:
Notes: Use Example 2: Extract Day Name Using date() FunctionIf you don’t want to use the
|