0

Hey,

I have a database of events... and I need to add a row for each day for a year... so there will be 365 rows in the database, but the date format must be as follows:

Row 1
Start Date: 2012-01-01T00:00
End Date: 2012-01-01T23:59

Row 2
Start Date: 2012-01-02T00:00
End Date: 2012-01-02T23:59

so... Y-m-d...

But im not sure on how to make the script work out the days in each month etc... Can someone help? Im inserting them into a table called events

Thanks Dan

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by pzuurveen
0

Solved :)

<?php
$itotal = 365;
$now = "1325289600";

$allDay = 1;
$eventName = "";
$newCalID = 4;
	
for ($i = 0; $i <= $itotal; $i++) {
    $startTime = date("Y-m-d", strtotime("+1 day", $now)) . "T00:00";
	$endTime = date("Y-m-d", strtotime("+1 day", $now)) . "T23:59";
	echo "INSERT INTO `events` (eventSummary, eventStart, eventEnd, eventAllDay) VALUES ('$eventName','$startTime','$endTime','$allDay');<br>";
	
	echo "<br /><br />";
	$now = strtotime("+1 day", $now);
}
?>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.