How to count days between two dates in PHP?

In this tutorial, we will write about calculating the number of days between two dates. This can be done very easily using the DateTime object that is available since PHP 5.3.

if you need to count number of days between two time zone read my previous post TimeZone conversion one timeZone to another php

Here is the simple function which will return number of days b/w given dates.

using Above function you can get years,months .. etc. see the commented code.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

Arjun
I am Arjun from Hyderabad (India). I have been working as a software engineer from last 7+ years, and its my passion to learn new things and implement them as a practice. Aside from work, I likes gardening and spending time with pets.
DMCA.com Protection Status