Calculating time differences

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rp
Forum Newbie
Posts: 21
Joined: Wed Nov 24, 2004 5:49 am

Calculating time differences

Post by rp »

Hi folks

This is one I always get "lost" on, calculating time differences.

need to calculate the time difference between $row['startdate'] (a 0000-00-00 date field in the db) and $datToday = date('Y,m,d');


Any help much appreciated.

Thanks
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Do mktime() on the start date, and then use time() to get the current time, and then subtract them, and then your left with the number of seconds from the start date and do what you like with that.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

or consider one of the many available date and time functions for your sql product and do the calculations there.....
Post Reply