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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:16:51+00:00 2026-06-12T19:16:51+00:00

I’m trying to accomplish the following task. I’m developing a custom calendar with three

  • 0

I’m trying to accomplish the following task. I’m developing a custom calendar with three views (day,week and month), there may be something out there already but I’m rewriting this as part of learning tool for me as well.

So user will face with Day view when they first visit, with arrows to go back and forth to next day or previous day of course. If they click on Week View, it will give them a 7 days overview with today date as default, and once again they can go back and forth to next week or previous week. The last view is the full month calendar, once they click on the day, it will give them the detail of the day and at the same time reset the default as the day they pick. So if they go back to week view, they will see the detail for the week contain the day that they picked. This is where I have trouble wrapping my head around with, I know there are PHP functions that determine the day of the week but I can’t seem to think about how to pass in the date and get the full week starting from Sunday for the day that passed in. For example, if I passed in 10/12/2012, I’d like to start the week at 10/07/12 – 10/13/12.

Thank you kindly for your help or pointing to the right direction. Please excuse my grammar/spelling mistakes as well.

  • 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-12T19:16:52+00:00Added an answer on June 12, 2026 at 7:16 pm
    1. Assuming that $selection represents the user’s selected date as an
      integer timestamp, date('N', $selection) will return a numeric
      representation of day of the week of their selection (e.g. Monday =
      1 through Sunday = 7).

      This result also represents the number of days since the start of
      the selected week (the previous Sunday) – $offset. Of course, if
      you’re beginning with a string representation of the users selected
      date (as in your question, 10/12/2012), you would first need to
      convert the date to an integer timestamp.

      $selection = strtotime($selection); //if $selection is in string format
      $offset = date('N', $selection);
      

    2. Now you may use $offset to establish date of the the start of the
      week (the previous Sunday) – $weekstart.

      $weekstart = strtotime("$selection -$offset day");
      

    3. Once you’ve got the start of the week, the end of the week
      ($weekend) is, of course, 6 days later, but to calculate this
      date, you first need to convert $weekstart from an integer
      timestamp into a string representation of the date. You’ll also need to convert the result ($weekend) into a string representation of the date.

      $weekstart = stringftime("%m/%d/%Y", $weekstart); //date format = 10/07/2012
      $weekend = strtotime("$weekstart +6 day");
      $weekend = stringftime("%m/%d/%Y", $weekend);
      


    So the following:

    $selection = "10/12/2012";
    $selection = strtotime($selection);
    $offset = date('N', $selection);
    $weekstart = strtotime("$selection -$offset day");
    $weekstart = stringftime("%m/%d/%Y", $weekstart);
    $weekend = strtotime("$weekstart +6 day");
    $weekend = stringftime("%m/%d/%Y", $weekend);
    
    $output = "Selected Date = $selection \n Selected Week = $weekstart - $weekend";
    
    echo $output;
    

    results in:

    Selected Date = 10/12/2012
    Selected Week = 10/07/2012 - 10/13/2020
    


    See:

    http://php.net/manual/en/function.date.php
    http://php.net/manual/en/function.strtotime.php
    http://php.net/manual/en/function.strftime.php

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group
I know there's a lot of other questions out there that deal with this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.