2013-04-26 37 views
2

日曆時區我有這個日曆時間:如何確定在Outlook

BEGIN:VCALENDAR 
VERSION:2.0 
PRODID:-//hacksw/handcal//NONSGML v1.0//EN 
BEGIN:VEVENT 
UID:[email protected] 
DTSTAMP:20130426T133000Z 
DTSTART:20130426T133000Z 
DTEND:20130426T143000Z 
SUMMARY:New Test 
DESCRIPTION: - http://www.domain.com/content/new-test 
LOCATION: 
END:VEVENT 
END:VCALENDAR 

,時間和日期都存儲在DTSTAMP,DTSTART和DTEND,但Outlook不會出現被追加時區信息到這些日期。無論如何要這樣做?我相信最後的Z是指「祖魯」時區或UTC。這個假設我錯了嗎?

我該如何讓Outlook認識到給定的時間是在EST中,並且如果用戶在CST中則更改它?有沒有辦法輕鬆做到這一點? (我自動生成iCal/vCal文件,因此,這個文件中的所有內容都可以直接控制)。我使用PHP來生成此文件(在技術上它是由一個Drupal模塊生成)

+0

Outlook存儲在UTC的一切,這使得它更容易處理夏令時和時區更改。 – 2013-04-26 14:18:18

回答

1

20130426 - 這是YYYYMMDD格式 133000Z - 1330的時間是格林尼治標準時間00Z只是一些額外的文本

嘿,我只是在做這個,本週這裏是我用來做它的代碼:

// DISPLAY CALENDER EVENT 
$startdate = date('Ymd',strtotime($startdate)); //needs the YYYYMMDD format 
$enddate = date('Ymd',strtotime($enddate)); //ends the day before the set date. So the date range is startdate(inclusive) -> enddate(exclusive) 
$startTime = gmdate('Hi',mktime($startminutes,$startseconds)); // This is in greenwhich mean time. Have the users input time normally and simply 
                   //explode on : 
$endTime = gmdate('Hi',mktime($endminutes,$endseconds)); 
$subject = 'yeah'; 
$desc  = 'come to this meeting'; 
$location = 'wherever'; 

$ical = "BEGIN:VCALENDAR 
VERSION:2.0 
PRODID:-//hacksw/handcal//NONSGML v1.0//EN 
BEGIN:VEVENT 
UID:" . md5(uniqid(mt_rand(), true))." 
DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . "Z 
DTSTART:".$startdate."T".$startTime."00Z 
DTEND:".$enddate."T".$endTime."00Z 
LOCATION:$location 
SUMMARY:".$subject." 
DESCRIPTION:".$desc." 
END:VEVENT 
END:VCALENDAR"; 

//set correct content-type-header 
header('Content-type: text/calendar; charset=utf-8'); 
header('Content-Disposition: inline; filename=calendar.ics'); 
echo $ical; 

這個網站有助於使這樣的:http://www.daveismyname.com/development/adding-events-to-microsoft-outlook-from-php-using-ical/