Prepare dates for datediff - w/mktime?

searched forums and got zero hits for this!

anyway could use a hand preparing for datediff. one date’s straight from MYSQL table in 2010-03-05 format. other I assemble from three pieces and it echos out as 201035.

so I thought mktime:
$calendar_date = date (“Y-m-d”, mktime(0,0,0,$year,$month,$i));
mktimes returns 1969-12-31 !! huh?

found something about “UNIX EPOCH” but still don’t get it.

I’m missing something very basic aren’t I, :confused:

many thanks!!

201035 is not valid.
2010-03-05 is valid.

Use strtotime(), not mktime().

You mention ‘date diff’ in your thread title, yet no mention of it within your post, what are trying to accomplish?

We maybe able to help you jump a few advance hurdles. :wink:

that did the trick, thanks Alien!

thanks Anthony - I’ll be back, I’m sure. :slight_smile:

ERRR… I spoke too soon. check out these results: you’re looking at days in a calendar.

1
2010-03-14
14
201031
2010-03-05
0 days diff

2
2010-03-08
7
201032
2010-03-05
0 days diff

3
2010-03-16
14
201033
2010-03-05
0 days diff

note that the result from STRTOTIME is stuck on 2010-03-05. but this seems impossible as it is constructed with the very same variable used to build the date displayed directly above it !!

here’s the code:

// the first line is of output (the 1, 2, & 3) is generated earlier

while (list($key, $value) = each ($events[$i]))
{
$start_date = $schedule_details[$value][‘0’];
$every = $schedule_details[$value][‘1’];
echo “<br>”.$start_date;
echo “<br>”.$every;
$cal_date = $year.$month.$i;
echo “<br>”.$cal_date;
$calendar_date = date(‘Y-m-d’, strtotime($year.$month.$i));
echo “<br>”.$calendar_date;
$datediff = $start_date - $calendar_date;
$fulldays = floor($dateDiff/(606024));
echo “<br>”.$fulldays ." days diff";
}

WHAT GIVES PLEASE ! here’s your chance Anthony ! :slight_smile:

and what’s wrong with datediff ??