Difference of two dates

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
glennalmeda
Forum Newbie
Posts: 14
Joined: Mon Jan 26, 2004 9:00 pm

Difference of two dates

Post by glennalmeda »

how can i get the difference of two dates..
for example i have 2004-03-05 and 2004-02-20

and i want the result in days...
thanks
glennalmeda
Forum Newbie
Posts: 14
Joined: Mon Jan 26, 2004 9:00 pm

Post by glennalmeda »

additional, i want to get the difference of two dates in DAYS excluding the saturdays and sundays...
what will be my code?
thanks..
User avatar
Ixplodestuff8
Forum Commoner
Posts: 60
Joined: Mon Feb 09, 2004 8:17 pm
Location: Queens, New York

Post by Ixplodestuff8 »

use the Unix timestamp for things like this.

use mktime to convert to unix time, then just subtract the two dates, and use date to convert back to somthing more human-understandable

edit: Add (60*60*24*2) per week to the time so that weekends aren't counted (too lazy to do the actual math :P )
Post Reply