Return Unix timestamp from iCal date time format
public iCalDateToUnixTimestamp ( string $icalDate ) : integer | ||
$icalDate | string | A Date in the format YYYYMMDD[T]HHMMSS[Z] or YYYYMMDD[T]HHMMSS or TZID=Timezone:YYYYMMDD[T]HHMMSS |
Результат | integer |
/** * Imports ical files. * * @param UploadedFile $file * @param Workspace $workspace * * @return int number of events saved */ public function importEvents(UploadedFile $file, $workspace = null) { $ical = new ICal($file->getPathname()); $events = $ical->events(); $tabs = []; foreach ($events as $event) { $e = new Event(); $e->setTitle($event->summary); $e->setStart($ical->iCalDateToUnixTimestamp($event->dtstart)); $e->setEnd($ical->iCalDateToUnixTimestamp($event->dtend)); $e->setDescription($event->description); if ($workspace) { $e->setWorkspace($workspace); } $e->setUser($this->tokenStorage->getToken()->getUser()); $e->setPriority('#01A9DB'); $this->om->persist($e); //the flush is required to generate an id $this->om->flush(); $tabs[] = $e->jsonSerialize(); } return $tabs; }
<?php $events = $ical->eventsFromRange('2016-03-01', '2016-04-31'); if ($events) { echo '<h4>Events March through April:</h4>'; } ?> <div class="row"> <?php foreach ($events as $event) { ?> <div class="col-sm-6 col-md-4"> <div class="thumbnail"> <div class="caption"> <h3><?php echo $event->summary . ' (' . date('d-m-Y H:i', $ical->iCalDateToUnixTimestamp($event->dtstart)) . ')'; ?> </h3> <?php echo $event->printData(); ?> </div> </div> </div> <?php } ?> </div> <?php $events = $ical->eventsFromInterval('1 week');