Page 1 of 1

Difference of two dates

Posted: Fri Feb 20, 2004 12:04 am
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

Posted: Fri Feb 20, 2004 12:32 am
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..

Posted: Fri Feb 20, 2004 1:34 am
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 )