Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 357179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:10:52+00:00 2026-05-12T12:10:52+00:00

How can I get the date for Monday and Friday for the current week?

  • 0

How can I get the date for Monday and Friday for the current week?

I have the following code, but it fails if current day is Sunday or Saturday.

$current_day = date("N");
$days_to_friday = 5 - $current_day;
$days_from_monday = $current_day - 1;
$monday = date("Y-m-d", strtotime("- {$days_from_monday} Days"));
$friday = date("Y-m-d", strtotime("+ {$days_to_friday} Days"));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T12:10:53+00:00Added an answer on May 12, 2026 at 12:10 pm

    Assuming your week starts on Monday you can use DateTime class with specific relative formats.

    To get the Monday and Friday for the current week:

    $mondayThisWeek = new DateTimeImmutable("monday this week");
    $fridayThisWeek = new DateTimeImmutable("friday this week");
    
    // so when current date is Sun, 07 Jan 2024
    // $mondayThisWeek will be Mon, 01 Jan 2024
    // $fridayThisWeek will be Fri, 05 Jan 2024
    

    To get Monday and Friday relative to a specific date:

    $referenceDate = new DateTimeImmutable("2024-01-07");
    $thatMonday = $referenceDate->modify("monday this week");
    $thatFriday = $referenceDate->modify("friday this week");
    
    // $thatMonday will be Mon, 01 Jan 2024
    // $thatFriday will be Fri, 05 Jan 2024
    

    If your week starts on (for example) Sunday then you will have to calculate Monday and Friday manually. Here is an example:

    $referenceDate = new DateTimeImmutable("2024-01-07");
    $dayOfWeek = (int) $referenceDate->format("w");
    // 0 = Sun
    // 1 = Mon
    // 2 = Tue
    // 3 = Wed
    // 4 = Thu
    // 5 = Fri
    // 6 = Sat
    
    if ($dayOfWeek === 0) {
        $mondayModifier = "next monday";
    } elseif ($dayOfWeek === 1) {
        $mondayModifier = "today";
    } else {
        $mondayModifier = "previous monday";
    }
    
    if ($dayOfWeek < 5) {
        $fridayModifier = "next friday";
    } elseif ($dayOfWeek === 5) {
        $fridayModifier = "today";
    } else {
        $fridayModifier = "previous friday";
    }
    
    $thatMonday = $referenceDate->modify($mondayModifier);
    $thatFriday = $referenceDate->modify($fridayModifier);
    
    // $thatMonday will be Mon, 08 Jan 2024
    // $thatFriday will be Fri, 12 Jan 2024
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I get the Sunday and Saturday of the week given a specific
Hallo. How can I get the date of last friday of current month with
In php i can get today date/day by using : $today = date('D, Y-m-d');
Is there a way I can get a date by the format MM/dd but
How can I get last year's start and end date using PHP code? Is
I have the following code on the timeline, but when I try and output
How can I get the week day for 20110828 (28th of August 2011)? I've
I can get the Monday of this week with: $monday = date_create()->modify('this Monday'); I
I have this: var d=new Date(); var weekday=new Array(7); weekday[0]=Sunday; weekday[1]=Monday; weekday[2]=Tuesday; weekday[3]=Wednesday; weekday[4]=Thursday;
I have date string: Monday, October 11, 2010. How can I create a NSDate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.