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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:07:05+00:00 2026-05-15T07:07:05+00:00

I am trying to create an array of weeks for users to select to

  • 0

I am trying to create an array of weeks for users to select to view stats week on week.

What I’m looking for is an array that has the timestamp of week start (monday 00.00 to sunday 11.59) that I can then use in MYSQL queries.

Has anyone got an code that might assist? I was thinking of doing something like:
EDIT, Thanks to the below answer:

‘ public function get_weeks () {
$valid_dates = array();
$date_counter = 0;
$date_counter = strtotime(“next thursday”); // I love being a lazy bastard!
$i = 0;

    while ($i < 10) {
       array_push($valid_dates, $date_counter);
       $date_counter = strtotime("previous sunday 23:59:59", $date_counter); 
       $i++;
     }

    foreach ($valid_dates as $date) {
        $values[$date]['start'] = $date;
        $values[$date]['end']   = $date + 604800;
    }

    return $values;
}'
  • 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-05-15T07:07:06+00:00Added an answer on May 15, 2026 at 7:07 am

    I wrote a solution for a similar question yesterday here. It was the wrong approach for the OP’s question but it goes into the right direction for your question. I can’t modify it right now due to time constraints, but it shouldn’t be too hard to do.

    Hint: Strtotime can do things like

    $timestamp = strtotime("last monday 0:00"); 
    strtotime("next sunday 23:59:59", $timestamp); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to cast an array of Objects for a week already in a
i am trying to create array like in the example i wrote above: $arr=array('roi
I'm trying to create an array of byte s whose length is UInt32.MaxValue .
I'm trying to create an array of JLabels, all of them should go invisible
I'm trying to create an array of checkboxes dynamically and also want to put
I am trying to create an array images to preload by getting each of
I am trying to create an array of functions so I can call one
I was trying to create 2D array in a continuous memory block, but it
I have a problem. I'm trying to create an array of different class objects
A few friends and myself have been working on an XNA RPG once a

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.