I have php code that pulls information needed from the database. The php date code is formatted in "format("Y-m-d H:i:s")". I am trying to get these dates from the database and add them to a calendar using JavaScript. I loop there the events that I want to add to the calendar. I have to different ways I found solutions for but neither one works.
<script type='text/javascript'>
<?php for($x = 0; $x < count($events); $x++) { ?>
var dateToConvert = new Date('<?php echo date(DATE_ISO8601, strtotime($events[$x]["startDate"])); ?>');
var startDate = dateToConvert.toISOString();
var endDate = '<?php echo date(DATE_ISO8601, strtotime($events[$x]["endDate"])); ?>';
var events = [
{
title: '<?php echo $events[$x]["name"]; ?>',
start: new Date(startDate),
end: endDate
}
];
<?php } ?>
</script>
I am assuming that I am missing something minor but I can't figure it out. I used the Chrome debugger and this is what I have as input. (2013-03-18T01:00:00-0600) It doesn't seem to have the Z at the end like it should.
The value in the database is (2013-03-18 01:00:00).
What am I missing?