Hi,
I have 2 dates like this:
2003-01-01 2003-03-01
I want to find out the number of days involved with those 2 dates. Is there an easy way to do this?
Thanks
Are you getting this from a mysql database? (Looks like you are).
If you are, then you can use this query, rather than doing it in php:
SELECT (TO_DAYS(HighDate) - TO_DAYS(LowDate)) AS difference FROM table
And if you are not using SQL, then
First, convert $date1 and $date2 to unix timestamps. Then...
echo "There are ".floor((date("U",$date2) - date("U",$date1)) / 86400)." days between the two dates specified.";
If you were using postgresql you would just:
select date1-date2 from table where ...