Skip to content
Menu Menu
  • Home
  • Posts
  • RSS
  • About
Expand Search Form
Open Widgets

Digital Tips & Tricks

© koenrogiers.be - Sharing is caring

Create ics file with all day event

Koen March 9, 2016 0


Recently I created my own ics calendar, I found many topics on google how to create it, but the difficult part was creating an all day event.

The DTSTART tag should only contain Ymd, no timestamp, only date. The DTEND tag can be deleted. I’ll show you my the necessary codes of my php file to create the ics format.

header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: inline; filename=calendar.ics');

echo "BEGIN:VCALENDAR\r\n";
echo "VERSION:2.0\r\n";
echo "NAME:My Calendar\r\n";
echo "X-WR-CALNAME: My Calendar\r\n";
echo "PRODID:-//hacksw/handcal//NONSGML v1.0//EN\r\n";

foreach ($events as $e) {
 echo "BEGIN:VEVENT\r\n";
 echo "UID:" . md5(uniqid(mt_rand(), true)) . "\r\n";
 echo "DTSTAMP:" . date('Ymd\THis\Z')."\r\n";
 echo "DTSTART:" . date('Ymd', $e->starttime) . "\r\n";
 //echo "DTEND:" . date('Ymd\THis\Z', $e->endtime) . "\r\n"; # hide for all day event
 echo "SUMMARY:" . $e->title ."\r\n";
 echo "END:VEVENT\r\n";
}

Happy coding!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *


Categories Code Tags calendar, ics, php, script
Previous: Add google calendar delegates to your smartphone
Next: Quick search for google drive – Chrome plugin
Close Widgets

Recent Posts

  • Meterstanden digitaal registreren
  • Mollie – Online betaalprovider

Tags

alias app apple bashprofile calendar certificate chrome cloud convert dropbox google ie internet explorer ipad iphone mac mail maximize microsoft mobile monitor move mp3 online operating system php pictures privacy search sharing shortcut snap ssl storage telenet terminal tips tool upload virtual virtualbox web window windows youtube

Recent Comments

  • Koen on Macbook shift lock voor cijfers / nummers
  • RoySie on Macbook shift lock voor cijfers / nummers
  • Tim on Crelan iPad app crasht bij opstarten
  • Patrick Goethals on Macbook shift lock voor cijfers / nummers
  • Patrick Goethals on Macbook shift lock voor cijfers / nummers

© koenrogiers.be | Disclaimer | Privacy Policy | RSS | Contact | Digital Tips & Tricks

We gebruiken cookies om ervoor te zorgen dat onze website zo soepel mogelijk draait. Als je doorgaat met het gebruiken van de website, gaan we er vanuit dat je ermee instemt.OkPrivacy policy