happypete Posted March 1, 2014 Share Posted March 1, 2014 I'm using the http://code.google.com/p/ics-parser/ to extract the start and end date from my ical file: $array =($ical1->events()); $newArray = array(); foreach ($array as $k => $v) { $newArray[$k]['startRange'] = date("Y-m-d", strtotime($v['DTSTART'])); $newArray[$k]['endRange'] = date("Y-m-d", strtotime($v['DTEND'])); } print_r(newArray) which returns this: Array ( [0] => Array ( [startRange] => 2013-07-14 [endRange] => 2013-07-26 ) [1] => Array ( [startRange] => 2013-08-02 [endRange] => 2013-09-12 ) [2] => Array ( [startRange] => 2013-10-06 [endRange] => 2013-10-10 ) [3] => Array ( [startRange] => 2013-10-17 [endRange] => 2013-10-28 ) [4] => Array ( [startRange] => 2013-11-05 [endRange] => 2013-11-13 ) [5] => Array ( [startRange] => 2013-11-14 [endRange] => 2013-11-23 ) [6] => Array ( [startRange] => 2013-12-18 [endRange] => 2014-01-05 ) ) OK, so I found this to print out all dates between a start and end date: $begin = new DateTime('2013-02-01'); $end = new DateTime('2013-02-07'); $daterange = new DatePeriod($begin, new DateInterval('P1D'), $end); foreach($daterange as $date){ echo $date->format("Y-m-d") . "<br>"; } This prints out: 2013-02-01 2013-02-02 2013-02-03 2013-02-04 2013-02-05 2013-02-06 The question: How do I do the same with the ical file to print out the start date, all the dates in between and the end date for each event and put it in an array like this: Array ( [0] => 2014-03-12 [1] => 2014-03-13 [2] => 2014-03-14 [3] => 2014-11-21 [4] => 2014-11-22 [5] => 2014-11-23 [6] => 2014-11-24 [7] => 2014-11-25 [8] => 2014-11-26 ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.