Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php I-Cal如何计算时间?_Php_Email_Icalendar - Fatal编程技术网

Php I-Cal如何计算时间?

Php I-Cal如何计算时间?,php,email,icalendar,Php,Email,Icalendar,我以UTC为单位计算时间,然后将时间转换为特定时区的时间,将其作为日历邀请发送 考虑一个日期函数,例如 $date = new DateTime('2012-07-17 09:00:00 +00'); //UTC $date->setTimezone(new DateTimeZone('America/Chicago')); echo $start_time=$date->format('H:i:s'); // echoes 04:00:00; // $ical .= "DTST

我以UTC为单位计算时间,然后将时间转换为特定时区的时间,将其作为日历邀请发送

考虑一个日期函数,例如

$date = new DateTime('2012-07-17 09:00:00 +00'); //UTC
$date->setTimezone(new DateTimeZone('America/Chicago'));

echo $start_time=$date->format('H:i:s'); // echoes 04:00:00; //
$ical .= "DTSTART:".$start."T".$start_time."\r\n";
但同时在前景方面,比如

$date = new DateTime('2012-07-17 09:00:00 +00'); //UTC
$date->setTimezone(new DateTimeZone('America/Chicago'));

echo $start_time=$date->format('H:i:s'); // echoes 04:00:00; //
$ical .= "DTSTART:".$start."T".$start_time."\r\n";
在美国没有给出上午9:00的时间,而是将日历时间设置为其他时间(上午9:30)。 我能做些什么来解决这个问题

非常感谢您的帮助。

看看一些示例,它似乎使用了
Ymd
T
His
Z格式,其中
T
Z
为文字

所以你想通过一些类似于:

$ical .= "DTSTART:".$date->format('Ymd\THis\Z')."\r\n";

在ical文件中,我对DTSTART的格式如下:
DTSTART;TZID=欧洲/柏林:20170922T200000
到目前为止没有问题。在这里你可以找到一份文件不,这也会以同样的方式触发…如果你看到亚洲/加尔各答;9:00:00的UTC为090000,其IST返回为143000,但当我将143000传递给ical时,它将邀请显示为晚上8点而不是上午9点。我不确定我在这里遗漏了什么,你应该输入UTC时间来参加活动。您正在通过IST,就像它是UTC一样,这使错误加倍(您提前11小时结束,这是5.5小时偏移量的两倍)谢谢。你是对的。同样在windows内部的某个地方,outlook计算已经开始了。因此必须减去偏移量。