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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:17:29+00:00 2026-06-11T15:17:29+00:00

I am trying to create a weekly calendar that allows the user to advance

  • 0

I am trying to create a weekly calendar that allows the user to advance or go back a week. So far I have this…

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

The the back and forward buttons work just fine and the $week_start variable which represents the first date of the week advances and goes back as it should but regardless of the date shown the $week_number and $year show as 01 and 1970 or 36 and 1600.

I know it must be something to do with the way I have tried to extract them from $display_week_ts but I don’t know what

  • 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-11T15:17:31+00:00Added an answer on June 11, 2026 at 3:17 pm

    The following looks out of place:

    $week_start = date('d-m-Y', $display_week_ts);
    $week_number = date("W", strtotime( $display_week_ts));
    $year = date("Y", strtotime( $display_week_ts));
    

    See how you’re using $display_week_ts in the first statement, but for the other (and similar) statements, you wrap that timestamp inside a call tostrtotime() which returns false.

    It’s best to just drop the strtotime() and use the variable as is:

    $week_number = date("W", $display_week_ts);
    $year = date("Y", $display_week_ts);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a weekly calendar that looks like this: http://dhtmlx.com/docs/products/dhtmlxScheduler/sample_basic.html How can
I am trying create a small web application that allows a user to login
I'm trying to create a cron job that will send a weekly newsletter. I
I'm trying create this function such that if any key besides any of the
I am trying to create a weekly reminder in my app. For this I
I'm trying create a log specifically for logging user account activity. I created this
Trying to create a background-image slideshow and am getting this error... This is the
I'm trying to create a sitemap that will automatically update. I've done something similiar
hi I'm trying create chat using node.js I see example in http://chat.nodejs.org/ I have
I'm trying create a box in my Django app that displays text (and possibly

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.