How to get all Dates between two Dates in PHP

Today, we will show you how to get all Dates between two Dates in PHP. Here, we get the all dates array between the given start and end date which can be used to get reports between two dates by daily, weekly, monthly, or yearly. we explain two different methods with simple example to return the dates in array.

Ways to get all dates between two dates

  1. Using strtotime() function
  2. Using date interval class

1. Using strtotime() function

In this method, we will use the strtotime() function to get the all dates between two dates.

We will create a function which contains only start date and end date parameters, that returns the array of dates between two dates.

2. Using date interval class

Let’s use the following code to get the list of dates between two dates using date interval class.

Output

You will get the following output.

I hope you find this article helpful.
Thank you for reading. Happy Coding..!! 🙂

If you found value in this article,
you can support us by buying me a coffee! ☕

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *