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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 239k
  • Answers 239k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer For one, since backtracking is a depth-first search it is… May 13, 2026 at 7:00 am
  • Editorial Team
    Editorial Team added an answer Tools -> Customize -> Check "Context Menus" -> Project and… May 13, 2026 at 7:00 am
  • Editorial Team
    Editorial Team added an answer The Connection object has an Errors collection you can spin… May 13, 2026 at 7:00 am

Related Questions

How can I get the Sunday and Saturday of the week given a specific
This is a nasty one for me... I'm a PHP guy working in Java
How can I get all items from a specific calendar (for a specific date).
Quicktime has a rich metadata API, allowing one to store all sorts of arbitrary

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.