Re: How to get the Days between to Dates?
| From: | David Robley | Date: | Mon, 03 Jul 2000 07:17:37 +0000 |
| Subject: | Re: How to get the Days between to Dates? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-4453@lists.php.net to get a copy of this message | ||
On 3 Jul, Edward Wong wrote:
> Hi, All:
>
> Now I encountered a question when I am tring to get the days between
> two Dates. eg: 1999-3-4 to 1999-8-23, How many days then?
>
> I can't find the function to figure out this, in fact, PHP4 provides
> less function on Dates and Times Calculation.
>
> Please give me a solution.
> Thanks.
Your PC thinks it is living in 1999!
See www.php.net/manual/ref.datetime.php for the small but effective set
of date/time functions.
In your case you could use mktime to convert the dates you want to
compare into a Unix timestamp (seconds) format, then subtract one from
the other and divide the difference by (24 * 60 * 60) to determine the
difference in days.
Cheers
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA