Reputation: 8359
Basicly when a user click on my download button I use href="download.php"
and from that day I add 84 days of calendar notifications to users calendar.
Problem I have is that daylight saving occurs and suddenly it changes to 09:00 after that daylight saving.
I want to stop that and make sure all calendar notifications gets 08:00.
But I cant seem to figure it out how to do that.
This my download.php code:
<?php
header("Content-type: text/calendar");//iphone
header("Content-Disposition: attachment; filename=pillintake.ics");//iphone
// the iCal date format. Note the Z on the end indicates a UTC timestamp.
define('DATE_ICAL', 'Ymd\THis\Z');
// max line length is 75 chars. New line is \\n
$output = "BEGIN:VCALENDAR
METHOD:PUBLISH
VERSION:2.0
PRODID:-//dev//test Schedule//EN\n";
$startTime = strtotime( date('Y-m-d 08:00') );
$endTime = strtotime($Date. ' + 84 days');
$startTime = str_replace("Z","",$startTime);
// Loop between timestamps, 24 hours at a time
$count = 1;
for ( $i = $startTime; $i <= $endTime; $i = $i + 86400 ) {
$currentDate = date(DATE_ICAL, $i);
$output .=
"BEGIN:VTIMEZONE
TZID:Europe/Stockholm
X-LIC-LOCATION:Europe/Stockholm
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
SUMMARY:Ta din tablett
DESCRIPTION: Glöm inte! \n\n
UID:0000".$count."
STATUS:OK
DTSTART:" . $currentDate . "
DTEND:" .$currentDate . "
LAST-MODIFIED:" .$currentDate . "
LOCATION:
END:VEVENT\n";
$count = $count +1;
}
$output .= "END:VCALENDAR";
echo $output;
?>
Upvotes: 1
Views: 703
Reputation: 96
You code looks good but there is something you may need to check. If your DTSTART value contains 'Z' then you will need to remove it.
Please try the following code:
...
$currentDate = date(DATE_ICAL, $i);
$currentDate = str_replace("Z","",$currentDate);
$output .=
"BEGIN:VTIMEZONE
TZID:Europe/Stockholm
X-LIC-LOCATION:Europe/Stockholm
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
SUMMARY:Ta din tablett
DESCRIPTION: Glöm inte! \n\n
UID:0000".$count."
STATUS:OK
DTSTART;TZID=Europe/Stockholm:" . $currentDate . "
DTEND;TZID=Europe/Stockholm:" .$currentDate . "
LAST-MODIFIED:" .$currentDate . "
LOCATION:
END:VEVENT\n";
$count = $count +1;
}
...
Hope this helps
Upvotes: 1
Reputation: 4775
Though your question is how to stop daylight saving changes I'll assume you just want your notification to always happen at the same local time regardless of the DST
.
You are almost there with your calendar file. The key point is like you did to define a VTIMEZONE
component, but you also need to tell the calendar tool which event property (DTSTART
, DTEND
, ...) should use this TZID
property
in your case your reminder should have two lines like this
...
DTSTART;TZID=Europe/Stockholm:20160323T00000 DTEND;TZID=Europe/Stockholm:20160323T00000
...
For more details you can refer to RFC5545- Time Zone Identifier and RFC5545 - event component
Upvotes: 1