2013-04-26 34 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/