working with dates

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
spartan7
Forum Commoner
Posts: 29
Joined: Sun Jun 19, 2005 12:09 am

working with dates

Post by spartan7 »

The issue is as follows :

I need to be able to calculate the amount of time that passes between two different dates.

eg.
$date1 = "5 Jun 2006 10:00"

$date2 = "7 Jun 2006 12:30"


I need to calculate the time it took between those two dates, and display the output as follows:
It took X days, X months, X years, X hours, X minutes, X seconds between date1 and date2

Is there a simple way of doing it?

Thanks
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

This has been asked several times recently. Search the board for 'Date Difference' and select 'Match all terms'. There are over 100 results.
Jeroen Oosterlaar
Forum Commoner
Posts: 37
Joined: Sun Nov 06, 2005 4:12 pm

Post by Jeroen Oosterlaar »

I believe you should be able to find some suitable solutions among the many plain date and time functions of PHP.
Post Reply