php

How to get first day of week in PHP

In this tutorial, we are going to see how to get the first day of the week in PHP. 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
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *