iCal feed import - Timezone query Has anyone got any experience working with iCal feeds - I have written a plugin utilising the CalFileParser library but the UK clock changes have thrown all the items out, so eg an all day event is now showing up as at 11pm the day before. For example:


BEGIN:VEVENT
DTEND:20170418T230000Z
DTSTAMP:20170412T114209Z
DTSTART:20170418T230000Z
SEQUENCE:0
SUMMARY:F4 Careers Day
UID:65d28288-9ba7-404c-85fe-b66682e2f605
END:VEVENT


Is importing as 23:00 on 18/04/2017. However importing the feed into Calendar (Mac) is reporting the event as expected at 00:00 on 19/04/2017.

If I update my site settings to BST (UTC+1) and parse the value into a DateTime object then it outputs to screen correctly, eg:

$tmp = DateTime::createFromString($item['dtstart']-&gt;date);

Outputs:

Craft\DateTime Object ( [date] =&gt; 2017-04-19 00:00:00.000000 [timezone_type] =&gt; 3 [timezone] =&gt; Europe/London )

However, on saving to my database record (to a column with AttributeType::DateTime) this date value is saved as 2017-04-18 23:00:00. This means that any attempt to retrieve and show this on my site outputs the wrong date/time.

Any thoughts on how to get my script to acknowledge the time difference and save this to the relevant record without having to tinker with the code every 6 months?

Cole
This sounds like that CalFileParser library you are using has some issues with timezones. There is a pull-request that supposedly fixes these, but I would rather exchange it for another library.

https://github.com/u01jmg3/ics-parser has the more modern codebase, seems to be actively maintained, more used, and can be installed using composer.