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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:50:06+00:00 2026-06-10T19:50:06+00:00

I am putting together a weekly view calendar but I am having problems when

  • 0

I am putting together a weekly view calendar but I am having problems when getting to October 28th which is when the clocks go forward. The calendar skips a day

My code so far…

//get viewed date from form and add either a week to it or take a week away
        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 {
                //sets the current day as the first day of the week so no good
                /*$display_week_ts = floor(time() / (3600 * 24)) * 3600 * 24;*/

                //Does't account for british summer time so days are out after 28th October
                $display_week_ts = strtotime("Monday noon");
        }

              $week_start = new DateTime(date("Y-m-d", $display_week_ts));

           for ($i = 0; $i < 7; $i++)  
       {
            echo '<td class="day">';
            $current_day_ts = $display_week_ts + ($i * 3600 *24);
            $daily_date = date('d-m-Y', $current_day_ts);
            $StartDate =  date('d', $current_day_ts);
            $MonthName = date('m', $current_day_ts);
            $Year = date('Y', $current_day_ts);
                            echo $daily_date;
                            echo '</td>';
        }

$week_start contains the value of the beginning of the week currently in view in the calendar. The first time it is opened the current week is displayed. If the next week button is pressed a week is added to the $week_start value. At present is saved in a hidden field in a table and posted back on submit. I have also tried storing $week_start as a TimeDate() object in a session

        $week_start = new DateTime(date("Y-m-d", $display_week_ts));
        $S_SESSION['week_start'] = $week_start;

But when I try to call the session back and use it move move a week forward

        $week_start = $S_SESSION['week_start'];
        $week_start->modify('+1 week');

I get the error ‘Warning: DateTime::modify() [datetime.modify]: The DateTime object has not been correctly initialized by its constructor’. After doing some digging I have found that DateTime doesn’t seem to support sessions until 5.3 and I am using 5.2.17

I would be really grateful if someone can help me workout a way to make the variable $week_start be the first day of the week represented by $display_week_ts in such a way that BST doesn’t cause a problem. I have been working on this solidly for 3 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-10T19:50:08+00:00Added an answer on June 10, 2026 at 7:50 pm

    use date_default_timezone_set('UTC');

    or
    $week_start->setTimezone(new DateTimeZone('UTC'));

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

Sidebar

Related Questions

I have been putting a weekly view calendar together that lets the user move
I'm just putting together a little POC project, and I'm having some weird issues
I am putting together a backbone example in which models are created edited and
I'm putting together a JavaScript object called ListBox which takes a two-dimensional array, and
I am putting together my first NSIS installer script, and having some trouble. I
I'm putting together a basic UITableView before getting some feedback of how the data
little background: currently putting together a website that is selling products, many of which
I'm putting together a portfolio website which includes a number of images, some of
I am currently putting together a rails-based web application which will only serve and
I'm putting together my blog at the moment - which includes a tag cloud

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.