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 6751229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:54:08+00:00 2026-05-26T12:54:08+00:00

How can I set a date range value for each week that gets updated

  • 0

How can I set a date range value for each week that gets updated dynamically as time goes on. I want to start the week on Monday and end on Sunday.

Example output would need to be 2011-10-24,2011-10-31

Using the below I am only getting the date of the month vs YYYY-MM-DD

<?php  
   $today = getdate();
   $weekStartDate = $today['mday'] - $today['mon']+1;
   $weekEndDate = $today['mday'] - $today['wday']+7;
   echo "week start date:".$weekStartDate;
   echo "<br/>";
   echo "week end date:".$weekEndDate;
?>
  • 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-26T12:54:08+00:00Added an answer on May 26, 2026 at 12:54 pm

    As mentioned in the comments, use DateTime.

    <?php
    $dt = new DateTime('Monday this week'); // yes, DateTime is that awesome
    $interval = new DateInterval('P6D'); // 6 days
    ?>
    
    <dl>
        <dt>Week start date:</dt>
        <dd><?php echo $dt->format('Y-m-d') ?></dd>
    
        <dt>Week end date:</dt>
        <dd><?php echo $dt->add($interval)->format('Y-m-d') ?></dd>
    </dl>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that I can set expiration date for a cookie, but can I
I am trying to set a javascript date so that it can be submitted
I have a set of rows, each with a date value, and I need
So I can set the date format on the Calendar Extender to it displays
How can i read cookie set date? In rails api I can not find
How can we set element to some default date in mysql ? In oracle
jQueryUI Datepicker documentation states that the minDate option can be set using a string
I'm attempting to create a listview that binds dynamically to a set of dates.
I'm grabbing some data from a database that has a stored date value, and
I can set the PHP include path in the php.ini : include_path = /path/to/site/includes/

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.