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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:26:10+00:00 2026-06-18T03:26:10+00:00

How to get name of days between two dates in PHP? Input: Start Date:

  • 0

How to get name of days between two dates in PHP?

Input:

Start Date: 01-01-2013
End date: 05-01-2013

Output:

Tuesday
Wednesday
Thursday
Friday
Saturday

Tried code

$from_date ='01-01-2013';
$to_date ='05-01-2013';

$number_of_days = count_days(strtotime($from_date),strtotime($to_date));

for($i = 1; $i<=$number_of_days; $i++)
{
    $day = Date('l',mktime(0,0,0,date('m'),date('d')+$i,date('y')));
    echo "<br>".$day;       
}


function count_days( $a, $b )
{       
    $gd_a = getdate( $a );
    $gd_b = getdate( $b );
    
    $a_new = mktime( 12, 0, 0, $gd_a['mon'], $gd_a['mday'], $gd_a['year'] );
    $b_new = mktime( 12, 0, 0, $gd_b['mon'], $gd_b['mday'], $gd_b['year'] );
    
    return round( abs( $a_new - $b_new ) / 86400 );
}

I saw the post Finding date of particular day between two dates PHP

But I don’t got my result
Please help me

  • 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-18T03:26:11+00:00Added an answer on June 18, 2026 at 3:26 am

    Use the DateTime class, it will be much more simple:

    $from_date ='01-01-2013';
    $to_date ='05-01-2013';
    
    $from_date = new DateTime($from_date);
    $to_date = new DateTime($to_date);
    
    for ($date = $from_date; $date <= $to_date; $date->modify('+1 day')) {
      echo $date->format('l') . "\n";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to get name of days between two dates in ios? Example: Input: Start
I have two EditText's. One with start date and other with end date. I
I am trying to find out how many days between two date the code
Possible Duplicate: How to calculate the difference between two dates using PHP? How to
when I calculate the difference between the start date and end date - it
How I can get name of parent activity in child activity. I have two
Possible Duplicate: get name of current PHP script in include file Can an included
There are many question posted about getting the difference between two dates in Oracle.
I'm trying to get the average number of days between when a user closes
I wrote code to get name of printer which is installed in my system.but

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.