Jump to content


Photo

write date range to table


  • Please log in to reply
4 replies to this topic

#1 proctk

proctk
  • Members
  • PipPipPip
  • Advanced Member
  • 300 posts

Posted 06 September 2006 - 10:48 PM

Hi

I'm still scratching my head on this one. I'm trying to write the date to a table between a certain date range. 

below is what I'm trying to work with


	$enddate = mktime(0, 0, 0, $endM, $endD, $endY);
	$startdate = mktime(0, 0, 0, $StartM, $startD, $startY);
	$d = $startdate - $enddate;

	echo $nextdate.'<br>';
	echo $startdate.'<br>';
	echo $d;

switch ($eventRepeat){

	case "daily":
		echo "<tr><td class='right'>";
	while($d < $i) { 
		
	echo "<tr><td>";
	echo "$row[event_description]";
	echo "</td><td>";
	echo "$row[event_category]";
	echo "</td><td>";
	echo "$row[event_details]";
	echo "</td></tr>";
 
    $i++;
    }
    
    break;
    
    default :
		
		}
		 }


#2 MarioRossi

MarioRossi
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 06 September 2006 - 11:09 PM

Think this one might need a more verbose explanation. I am struggling to work out what it is you are trying to achieve.

You are generating 2 timestamps based on a start date and end date.

you are the subtracting the enddate from the startdate giving you a negative? I suspect this should be the other way round to give you number of seconds between the start and end date? correct?

and then you lose me...

#3 proctk

proctk
  • Members
  • PipPipPip
  • Advanced Member
  • 300 posts

Posted 06 September 2006 - 11:21 PM

Your write my subtract is backwards

say

the start date is 2006-09-06
the end date is 2006-09-20

i wnat to echo all the date starting with the start date to the end dat in a table


#4 MarioRossi

MarioRossi
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 06 September 2006 - 11:42 PM

ah right ok now i get you why not do this.....

get your starttime and endtime timestamps using mktime() like you are and then start a loop adding 86400 (seconds in a day) on each iteration until you get to your enddate?

If you are working with dates a lot you may want to check out http://pear.php.net/...me.calendar.php

#5 proctk

proctk
  • Members
  • PipPipPip
  • Advanced Member
  • 300 posts

Posted 06 September 2006 - 11:47 PM

I don't understand how to create the loop for this.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users