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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:04:07+00:00 2026-06-10T21:04:07+00:00

I have been putting a weekly view calendar together that lets the user move

  • 0

I have been putting a weekly view calendar together that lets the user move back or forwards a week using buttons on a form. Everything works well except that when the calendar first opens it this that the current day if the beginning of the week so the rest of the days are all out.

Here’s what I have so far…

if(isset($_POST['add_week'])){
     $last_week_ts = strtotime($_POST['last_week']);
     $display_week_ts = $last_week_ts + (3600 * 24 * 7);
} else if (isset($_POST['back_week'])) {
     $last_week_ts = strtotime($_POST['last_week']);
     $display_week_ts = $last_week_ts - (3600 * 24 * 7);
} else {
    $display_week_ts = floor(time() / (3600 * 24)) * 3600 * 24;
}

$week_start = date('d-m-Y', $display_week_ts);

for ($i = 0; $i < 7; $i++) {
    $current_day_ts = $display_week_ts + ($i * 3600 *24);
    echo date('d-m-Y', $current_day_ts); 
}

I know what the problem is, the line

$display_week_ts = floor(time() / (3600 * 24)) * 3600 * 24;

It calls the current day but $week_start needs to be the first day of the week but I have tried everything I can find. I have tried

$display_week_ts = strtotime("Monday noon");

which seems to work well until the diary reaches Monday 29th October at which point it seems to skip a day and makes 29th October a Tuesday instead.

I found another topic on this site that found the beginning of the week but I have been unable to implement any of them successfully

I will be very grateful for any assistance in this matter, I’ve been working on it for three days now…

  • 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-06-10T21:04:09+00:00Added an answer on June 10, 2026 at 9:04 pm

    Try this:

    $display_week_ts = floor(time() / (3600 * 24)) * 3600 * 24; 
    $dow = date("w", $display_week_ts);
    $dow = ($dow + 6) % 7;
    $display_week_ts -= $dow * 3600 * 24;
    
    $monday = new DateTime(date("Y-m-d", $display_week_ts));
    

    Now $monday contains the date for Monday of the current week. Store this object in the session. When you need to move to next week, find the next Monday with

    $monday->modify('+1 week');
    

    To find the previous Monday, use

    $monday->modify('-1 week');
    

    After finding the new Monday, store it back into the session.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am putting together a weekly view calendar but I am having problems when
I am to c# and have been putting programs together through modification of existing
I have been putting only jQuery mask so far, but I figured out that
I have been putting together a bash script and within it I need to
I have been putting my entire index into memory using RAMDirectory to improve performance
I am putting together some ideas for our automated testing platform and have been
I've been putting together a list of pages that we need to update with
The past months I have been putting together my own QtWebKit-based browser ( WildFox
I have been putting my code on github, but I've run into an implementation
I have been putting off developing this part of my app for sometime purely

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.