php - ICS file dynamic timezone issue -


this question has answer here:

i trying generate ics file dynamically in php, timezone dynamic according location given. works there daylight time issue i.e shows time difference of 1 hour or so. solve issue have use daylight dynamically. don't know how use dynamically, or can tzoffsetfrom , tzoffsetto offsets related timezone given.

for example:

    $timezone = "america/denver" // dynamically fetched db        $ical = "begin:vcalendar\n";       $ical .= "version:2.0\n";       $ical .= "prodid:-//lokalmotion//lokalmotion events v1.0//en\n";       $ical .= "calscale:gregorian\n";       $ical .= "method:publish\n";       $ical .= "x-wr-calname:lokalmotion events\n";       $ical .= "x-ms-olk-forceinspectoropen:true\n";       $ical .= "begin:vtimezone\n";       $ical .= "tzid:{$timezone}\n";       $ical .= "tzurl:http://tzurl.org/zoneinfo-outlook/{$timezone}\n";       $ical .= "x-lic-location:{$timezone}\n";       $ical .= "end:vtimezone\n";       $ical .= "begin:vevent\n";       $ical .= "dtstamp:".date('ymd\this\z')."\n";       $ical .= "dtstart;tzid={$timezone}:{$start_date}\n";       $ical .= "dtend;tzid={$timezone}:{$end_date}\n";       $ical .= "status:confirmed\n";       $ical .= "summary:{$title}\n";       $ical .= "description:{$description}\n";       $ical .= "organizer;cn=reminder:mailto:support@mysite.com\n";       $ical .= "class:public\n";       $ical .= "created:{$start_date}z\n";       $ical .= "location:{$location}\n";       $ical .= "url:http://www.mysite.com\n";       $ical .= "sequence:1\n";       $ical .= "last-modified:".date('ymd\this\z')."\n";       $ical .= "uid:{$title}-support@mysite.com\n";       $ical .= "end:vevent\n";       $ical .= "end:vcalendar";      echo $ical; 

now how use daylight dynamically according location, location can 'america/caracas' .. etc

$ical .= "begin:daylight"; $ical .= "tzoffsetfrom:{}"; //i need dynamic $ical .= "tzoffsetto:{}";//i need dynamic $ical .= "tzname:edt"; $ical .= "dtstart;tzid={$timezone}:{$start_date}\n"; $ical .= "rrule:freq=yearly;bymonth=3;byday=2su"; $ical .= "end:daylight"; 

thanks in advance.

before converting times , date, should set correct timezone in php engine knows time characteristics of zone using:

date_default_timezone_set('america/mexico_city'); $start_date = date('c', time());   // iso date 8601 of "right now" $start_zone = date('o', time());   // tzoffsetfrom format  of "right now"  date_default_timezone_set('america/denver'); $to_zone = date('o', time());   // tzoffsetto of "right now" 

hope may help


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -