I want to insert all the dates between a starting and an end date into a table in my database.
I already found a code for the two dates and the dates between.
The problem now is that the dates are not inserted into my database when running the code. Only 0000-00-00 is displayed in my date table.
Also no error message occurs when running the code so I don't know where I made a mistake. Can someone help me with this problem?
Here is my Code:
$begin = new DateTime('2010-05-01');
$end = new DateTime('2010-05-10');
$interval = DateInterval::createFromDateString('1 day');
$period = new DatePeriod($begin, $interval, $end);
foreach ($period as $dt) 
{
  $newdate = $dt->format("Y-m-d ");
  $statement = $pdo->prepare("INSERT INTO table (date) VALUES ($newdate)");
  $statement->execute();
}