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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:16:48+00:00 2026-05-20T11:16:48+00:00

I am trying to loop through dates with PHP. Currently my code gets stuck

  • 0

I am trying to loop through dates with PHP. Currently my code gets stuck in a loop repeating 110307. I need the date format to be in yymmdd. Here is what I was trying to use:

<?php
    $check_date = '100227';
    $end_date = '100324';

    while($check_date != $end_date){
        $check_date = date("ymd", strtotime("+1 day", strtotime($check_date)));
        echo $check_date . '<br>';  
    }
?>
  • 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-20T11:16:49+00:00Added an answer on May 20, 2026 at 11:16 am

    strtotime interprets “100227” as the time 10:02:27 today, not 2010-02-27. So after the first step, $check_date (today) is “110307”. At all subsequent steps “110307” is again interpreted as a time today, giving $check_date as “110307” again.

    A neat trick for iterating dates is to take advantage of mktime’s ability to normalize dates, something like this:

    $date_arr = array(27,2,2010);
    $end_date = "100324";
    do {
        $check_date = gmdate('ymd', gmmktime(0,0,0,$date_arr[1],$date_arr[0]++,$date_arr[2]));
        echo $check_date."\n";
    } while($end_date!=$check_date);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having problems with my JScript code. I am trying to loop through
I'm currently trying to write some Javascript to loop through the elements in a
I'm a bit stuck trying to loop through a table row, calculate the values
I'm trying to loop through items of a checkbox list. If it's checked, I
I am trying to loop through an array of usernames and for each username,
I'm trying to loop through EACH DAYof the WEEK between 2 time periods DateTime
I'm trying to create a script that will loop through files that have their
I'm trying to loop through an array backwards, so I figured I could try
I am trying to loop through authors in my wordpress blog but something weird
I'm trying to loop through all event subscriptions for an object that : INotifyPropertyChanged

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.