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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:28:25+00:00 2026-06-17T02:28:25+00:00

I am preparing a festival site. I have a table with a datetime field

  • 0

I am preparing a festival site. I have a table with a datetime field for the festival dates.
Festival will be in between “6 / March / 2013″ and ” 7 / April / 2013″.
So I created the loop as in these answer here :

Schema::create('dates',function($table)
        {
            $table->increments('id');
            $table->date('date');
            $table->timestamps();
        });
        $starting_date = new DateTime('2013-03-06');
        $ending_date = new DateTime('2013-04-06');

        $interval = DateInterval::createFromDateString('1 day');
        $period = new  DatePeriod($starting_date , $interval, $ending_date);

        foreach($period as $dt)
        {

        DB::table('dates')->insert(array(
        'date' => $dt
        ));

        }

The database is filled until 4th of april , the loop does not add more than 30 days.
Can you help me to find a fix for missing days ?

ps: I used alternative while loop resulting same:

    $starting_date = new DateTime('2013-03-06');        
            $ending_date = new DateTime('2013-04-07');

            while($starting_date <= $ending_date){
                DB::table('dates')->insert(array(
                    'date' => $starting_date
                ));

            }
    $starting_date->add(new DateInterval('P1D'));
}
  • 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-17T02:28:26+00:00Added an answer on June 17, 2026 at 2:28 am
    just add 23:59:59 to the end of the $ending_date
    $starting_date = new DateTime('2013-03-06 00:00');
    $ending_date = new DateTime('2013-04-06 23:59:59');
    
    
    $interval = new DateInterval('P1D');
    $period = new  DatePeriod($starting_date , $interval, $ending_date);
    foreach ($period as $date) {
        echo $date->format('Y-m-d')."<br/>";
    }
    print_r($period);exit;
    

    Which outputs

    2013-03-06
    2013-03-07
    2013-03-08
    2013-03-09
    2013-03-10
    2013-03-11
    2013-03-12
    2013-03-13
    2013-03-14
    2013-03-15
    2013-03-16
    2013-03-17
    2013-03-18
    2013-03-19
    2013-03-20
    2013-03-21
    2013-03-22
    2013-03-23
    2013-03-24
    2013-03-25
    2013-03-26
    2013-03-27
    2013-03-28
    2013-03-29
    2013-03-30
    2013-03-31
    2013-04-01
    2013-04-02
    2013-04-03
    2013-04-04
    2013-04-05
    2013-04-06

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

Sidebar

Related Questions

While preparing to deploy a MongoDB powered site to a clients web server, their
I am preparing an Excel sheet in which I have to maintain the version
I'm preparing my paypal system and have a separate page that forwards the user
I'm preparing for a quiz, and I have a strong suspicion I may be
I'm preparing to embark on a web app development that will make little to
I am preparing for Magento certification and this question really stuck me in between.
I am preparing for an exam and I have stumbled on the following question:
I am preparing a new database server, where I will migrate data from a
I'm preparing a test env. for my project. I have a bunch of maven
I am preparing a new database server, where I will migrate data from 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.