Get Date Range Of Current Week in PHP

In PHP many useful date functions are present. One I found very useful for a project was finding the Date range of the current week. With the below code, you can find the start and end date of the current week.

This Sunday will be the start of the week and this Saturday will be the end of the week.

$currentweekstart = date("M jS Y",strtotime('sunday last week'));
$currentweekend = date("M jS Y",strtotime("saturday this week"));

Here in the variable $currentweekstart , we can get the week start date and in $currentweekend we will get the end of the week.

So the week range will be :


$currentweekdate = $currentweekstart.' - '.$currentweekend;


Hope this helps!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s