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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:09:52+00:00 2026-06-11T19:09:52+00:00

I have a pagination function which pages through a time table and advances the

  • 0

I have a pagination function which pages through a time table and advances the dates on a weekly basis and displays the details relevant to the new dates.

Whilst testing some new data I encountered a paging problem. In that it would not page passed 22/10/2012.

Debugging the code I eventually found the source of the problem which is that incrementing the date stamp representing 22/10/2012 by 7 days returned (via strftime) a date of 28/10/2012 when obviously I was expecting a date of the 29/10/2012. This error effectively causing a continuous loop as %W (which drives the weekly pagination) is 43 for 22/10/2012 and 43 for 28/10/2012 and of course it should be 44 for 29/10/2012.

In a quick test to isolate and recreate this problem I used the following:

/*
 * test %W
 */

$time_Stamp_1 = mktime(0,0,0,10,22,2012);
echo "date : " . strftime("%d/%m/%Y", $time_Stamp_1);
echo "W for first time stamp " . $time_Stamp_1 . " is " . strftime("%W", $time_Stamp_1); 

$time_Stamp_1a = $time_Stamp_1 += (60 * 60 * 24 * 7);
echo "new date : " . strftime("%d/%m/%Y", $time_Stamp_1a);
echo "W for new date time stamp: " . strftime("%W", $time_Stamp_1a);

$time_Stamp_2 = mktime(0,0,0,10,29,2012);
echo "W for second time stamp: " . strftime("%W", $time_Stamp_2);

The pagination happily moves between all the other weeks I have tested and obviously uses this increment / decrement as appropriate.

Hopefully I am missing something obvious. Any thoughts?

  • 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-11T19:09:53+00:00Added an answer on June 11, 2026 at 7:09 pm

    The PHP DateTime class is the way to go:-

    $inFormat = 'd/m/Y h:i';
    $outFormat = 'd/m/Y';
    $date = DateTime::createFromFormat($inFormat, '22/10/2012 00:00');
    $interval = new DateInterval('P7D');
    for($i = 0; $i < 10; $i++){
        $date->add($interval);
        var_dump($date->format($outFormat) . " is in week " . $date->format('W'));week');
    }
    

    Gives the following output:-

    string '29/10/2012 is in week 44' (length=24)
    string '05/11/2012 is in week 45' (length=24)
    string '12/11/2012 is in week 46' (length=24)
    string '19/11/2012 is in week 47' (length=24)
    string '26/11/2012 is in week 48' (length=24)
    string '03/12/2012 is in week 49' (length=24)
    string '10/12/2012 is in week 50' (length=24)
    string '17/12/2012 is in week 51' (length=24)
    string '24/12/2012 is in week 52' (length=24)
    string '31/12/2012 is in week 01' (length=24)
    

    Which, a quick glance at a calendar tells me, is correct.

    See here for valid format strings http://us.php.net/manual/en/datetime.createfromformat.php
    Also see the DateInterval class.

    See here for valid output formats for DateTime::format() http://us.php.net/manual/en/function.date.php

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

Sidebar

Related Questions

I currently have pagination functionality that displays the total page count, but I was
I have a fairly simple pagination query used to get rows from a table
I have an application with associations and will pagination the pages. The index page
I have a pagination script, which can be seen here: http://www.automotori6282.tk/phpsandbox/ This is the
I have a pagination script which I have posted below, the problem is I
I have a problem. I have getAllJobsControllerUrl() function which return url with specific parameters:
I have a php code which generates pagination links. I have ol > li
I have a slideshow that requires custom markup for the pagination, which also includes
I Have a working PHP Based Pagination onto which i am adding ajax to
i have a pagination script which working with jquery and php scripts, i am

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.