PHP Function to create Email Calendar Entry - Change to Full Day Event

Please see the below function that creates an email with a calendar entry for Outlook..

I need to change this to a full day event currently it adds over two days. Day one 01:00 - Day two 00:59 ?


<?php
function sendIcalEvent($from_name, $from_address, $to_name, $to_address, $to_auth_name, $to_auth_address, $startTime, $endTime, $type, $description, $location,$Uid,$status = false)
{
	ini_set('SMTP', 'SMTPREMOVED');
	
	$to = $to_address.",".$to_auth_address;
	if($type == "half"){
		$subject = "Holiday add Half Day - ".$to_name;
	}
	else{
		$subject = "Holiday add - ".$to_name;
	}
     //Need to add in the requestors name
    if($status){
		
		$subject = "Holiday remove - ".$to_name; //Need to add in the requestors name
	}
	$organizer          = 'EMAILREMOVED';
    $organizer_email    = 'EMAILREMOVED';
     
     
    $location           = "Out Of Office";
    $date               = date("Ymd",strtotime($startTime));
    $startTime          = '0000';
    $endTime            = '2359';
    //$subject            = 'Millennium Falcon';
    $desc               = 'Holiday';
	$from  = "EMAILREMOVED";
	$headers = "From: $from\r\nReply-To: $from"; 
	$headers .= "\r\nMIME-version: 1.0\r\nContent-Type: text/calendar; name=calendar.ics; method=REQUEST; charset=\"iso-8859-1\"";
	$headers .= "\r\nContent-Transfer-Encoding: 7bit\r\nX-Mailer: Microsoft Office Outlook 12.0"; 
 
    $message = "BEGIN:VCALENDAR\r\n";
    $message .= "VERSION:2.0\r\n";
    $message .= "PRODID:-//Deathstar-mailer//theforce/NONSGML v1.0//EN\r\n";
	if($status){
		$message .= 'METHOD:CANCEL' . "\r\n";
		$message .= 'STATUS:CANCELLED'. "\r\n";		
	}
	else{
		$message .= 'METHOD:REQUEST' . "\r\n";
	}
    $message .= "BEGIN:VEVENT\r\n";
    $message .= "UID:" . $Uid ."\r\n";
    $message .= "DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . "Z\r\n";
    $message .= "DTSTART:".$date."T".$startTime."00Z\r\n";
    $message .= "DTEND:".$date."T".$endTime."00Z\r\n";
    $message .= "SUMMARY:".$subject."\r\n";
    $message .= "ORGANIZER;CN=".$organizer.":mailto:".$organizer_email."\r\n";
    $message .= "LOCATION:".$location."\r\n";
    $message .= "DESCRIPTION:".$desc."\r\n";
    $message .= "END:VEVENT\r\n";
    $message .= "END:VCALENDAR\r\n";
	
	
    $headers .= $message;
    mail($to, $subject, $message, $headers); 
	
}

Open in new window

adznonAsked:
Who is Participating?
 
Julian HansenConnect With a Mentor Commented:
Try this
...
$message .= "DTSTART;VALUE=DATE:{$date}\r\n";
$message .= "DTEND;VALUE=DATE:{$date}\r\n";

Open in new window

According to the docs if you specify the type of the DTSTART as a date and leave out the End Date with Start Date being a date only (no time) then it will load as an all day event.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.