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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:29:19+00:00 2026-06-10T18:29:19+00:00

Possible Duplicate: Php.Advance weekly calendar one week I have written a script that displays

  • 0

Possible Duplicate:
Php.Advance weekly calendar one week

I have written a script that displays a calendar week by week that the user can chose to go back or forward a week at a time. Everything works great except the first week of every year still displays the wrong year and the 31st December shows as 02/01. It seems that only week 1 is affected, the days are correct again in week and onwards

<?
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);
    $week_number = date("W", $display_week_ts);
    $year = date("Y", $display_week_ts);

echo $week_start.' '.$week_number.' '.$year;
?>

<table name="week">
    <tr>
<?
for($day=1; $day<=7; $day++)
{
    echo '<td>';
    echo date('d-m-Y', strtotime($year."W".$week_number.$day))." | \n";
    echo '</td>';
}
?>
</tr>
<tr>
<form name="move_weeks" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name="last_week" value="<? echo $week_start; ?>" />
<td colspan="7"><input type="submit" name="back_week" value="back_week" /><input type="submit" name="add_week" value="add_week" />
</td>
</form>
</tr>
</table>

Any help will be appreciated

  • 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-10T18:29:21+00:00Added an answer on June 10, 2026 at 6:29 pm

    As suggested in the answer to the original question, you need to not use the week number and year number stuff.

    If at the end of the day, you want to be able to list seven days for the week, just do not use this section of code at all:

    $week_number = date("W", $display_week_ts);
    $year = date("Y", $display_week_ts);
    
    echo $week_start.' '.$week_number.' '.$year;
    

    And replace the loop that echos out with the loop suggested in the original question.

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

Sidebar

Related Questions

Possible Duplicate: PHP - send file to user I have written a script that
Possible Duplicate: php false place in condition I have noticed that a lot of
Possible Duplicate: Simple PHP Mailer Script i run a small website and we have
Possible Duplicate: Headers already sent by PHP My problem is that I have a
Possible Duplicate: using seo user friendly in php I have 3 PHP files: index1.php,
Possible Duplicate: PHP 2-way encryption: I need to store passwords that can be retrieved
Possible Duplicate: Guessing User's TimeZone in PHP How can i get my system current
Possible Duplicate: PHP Get end string on url between / and / I have
Possible Duplicate: php loop through associative arrays i have a variable which prints an
Possible Duplicate: php loop through associative arrays i have this piece of code which

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.