Datediff help NEEDED

why is my diff always coming up zero? have done all I can think of.

this code:
$start_date_values = $schedule_details[$value][‘0’];
$calendar_date_values = $year.“-”.$month.“-”.$i;
$calendar_date = date(‘Y-m-d’, strtotime($calendar_date_values));
$start_date = date(‘Y-m-d’, strtotime($start_date_values));
$every = $schedule_details[$value][‘1’];

echo "<br>".$every;
echo "<br>".$start_date;
echo "<br>".$calendar_date;

$datediff = $start_date - $calendar_date;
echo “<br>”. $datediff;
$fulldays = floor($datediff/(606024));
echo “<br>”. $fulldays ." days diff";

spits up:
2010-03-14
2010-03-01
14
0
0 days diff

another question please:
this result should be +, but if it were - would it say so?

Because you’re trying to do arithmetic on strings. php tries to be helpful when it sees you doing subtraction with strings, but it can only help you so much. It converts your string values to numbers using the following rules
http://www.php.net/manual/en/language.types.string.php#language.types.string.conversion

So, the result is 2010, for both values in this case.

2010 minus 2010 equals 0

Maybe you meant to subtract the unix timestamps from each other.

was totally lost. that puts me on the right path. THANKS malibu!

ummm… is unix timestamp what we get from mktime, because I tried mktime first (instead of strtotime) and got back garbage.

bottom line - best way to change what I have to timestamps?

thanks again!

yes, mktime() returns a unix timestamp. So does strtotime(). The php manual does describe these functions.

okay cr, that helps - sort of…
confused to learn strtotime returns a unix timestamp, as the strings I am comparing ARE THE PRODUCT of strtotime. maybe that’s the problem, that I’m comparing the products, I don’t know.

anyway going to call it a night and consult manual tomorrow. THANK YOU for your help cr.

if you’re feeling gracious don’t hesitate to chime in, that manual can be cryptic :slight_smile: