如何格式化ical和outlook日历的日期时间

如何格式化ical和outlook日历的日期时间,outlook,calendar,icalendar,Outlook,Calendar,Icalendar,我正在尝试将事件添加到google、outlook和ical日历中。将事件添加到google日历工作正常,但对于outlook和ical来说,在时间上存在一些问题。 当我为同一日期添加1:00 pm的开始时间和12:00 am的结束时间时,ical将生成12:00 am的结束时间和1:00 pm的结束时间。我正在生成如下的ical。我不知道我做错了什么?欢迎提供任何帮助/建议 $startDate = $_GET['startDate']; $startTime = $_GET['startTi

我正在尝试将事件添加到google、outlook和ical日历中。将事件添加到google日历工作正常,但对于outlook和ical来说,在时间上存在一些问题。 当我为同一日期添加1:00 pm的开始时间和12:00 am的结束时间时,ical将生成12:00 am的结束时间和1:00 pm的结束时间。我正在生成如下的ical。我不知道我做错了什么?欢迎提供任何帮助/建议

$startDate = $_GET['startDate'];
$startTime = $_GET['startTime'];
$startDateTime = $startDate . ' ' . $startTime; //2020-10-08 13:00:00
$endDate   = $_GET['endDate'];
$endTime   = $_GET['endTime'];
$endDateTime = $endDate . ' ' . $endTime; //2020-10-08 00:00:00
$subject   = $_GET['subject'];
$desc      = $_GET['desc'];
$location  = $_GET['location'];
$filename  = $subject . '.ics';

$format = 'Y-m-d H:i:s';
$icalformat = 'Ymd\THis';

$startDateTime = DateTime::createFromFormat($format, $startDateTime);
$startDateTime = $startDateTime->format( $icalformat );
$endDateTime = DateTime::createFromFormat( $format, $endDateTime );
$endDateTime = $endDateTime->format( $icalformat );

$ical = "BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
UID:" . md5( uniqid( mt_rand(), true ) ) . "example.com
DTSTAMP:" . gmdate('Ymd') . 'T' . gmdate( 'His' ) . "
DTSTART:" . $startDateTime . "
DTEND:" . $endDateTime . "
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: attachment; filename=' . $filename );
echo $ical;
exit;

结束时间怎么可能早于开始时间?难道不是第二天的午夜吗?2020-10-0900:00:00