Does anyone know if there is a ready function that would give me the number of days between two dates? For example if I'd need the number of days between 2000-10-20 and 2000-11-15. If there isn't a function for this, could someone please help me with this problem?
Thanks in advance,
Tuomo
I turn to trusty PostgreSQL for this most of the time.. Are you using PostgreSQL by chance? If not you could do this..
Parse your date into month day and year, use mktime() to generate a timestamp, pass that to date() like : date("t",yourtimestamp) (that gives you the number of days in the given month) -- keep a running total of that and viola..
There might be an easier way but that's about a 20 second thought written down :-)
Don't forget a timestamp represents the number of second since 1970-1-1. So simply do something like this :
$t1=mktime(0,0,0,$m1,$d1,$y1,0); $t2=mktime(0,0,0,$m2,$d2,$y2,0); $days=($t2-$t1)/3600/24;
Et voilĂ !