You are here: Home / Topics / How to get first day of week in PHP

How to get first day of week in PHP

Filed under: PHP on 2023-06-30 06:32:31

You can use strtotime() function to get the first day of the week using PHP. This function returns the timestamp of the default time variable, then uses date() function to convert the date from the timestamp to a meaningful date.

In PHP the week starts with Monday, so if the time string is given as “this week” the result will be Monday’s timestamp, which can make it readable by passing it through date() function.
 

How to get first day of week in PHP
 

<?php 
 setlocale(LC_TIME, "English");
 $firstDay = strftime("%A - %d/%M/%Y", strtotime("this week")); 
   
 echo "First day of this week is: ", $firstDay;
?>


Output:

First day of this week is: Monday - 15/12/2019

About Author:
V
Vinay Kumar     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.