I'll start off by saying that I am not a PHP developer. So I had another developer create a plugin that takes the start and end time from the Wordpress plugin CalendarizeIt and outputs that into a formatted ICS url. The problem is that the url is outputting a start and end time 5 hours earlier than it should.
Here's the plugin PHP:
<?php
// Original script from http://jamiebicknell.tumblr.com/post/413492676/ics-generator-php-class#_=_
// Modified by Sean Carruthers
$start = $_GET['start'];
$end = $_GET['end'];
$name = $_GET['name'];
$description = $_GET['description'];
$location = $_GET['location'];
$uid = "kaneko" . strtotime("now");
$data = "BEGIN:VCALENDAR
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
DTSTART:".date("Ymd\THis\Z",$start)."
DTEND:".date("Ymd\THis\Z",$end)."
LOCATION:".$location."
TRANSP: OPAQUE
SEQUENCE:0
UID:".$uid."
DTSTAMP:".date("Ymd\THis\Z")."
SUMMARY:".$name."
DESCRIPTION:".$description."
PRIORITY:1
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR";
header("Content-type:text/calendar; charset=utf-8");
header('Content-Disposition: inline; filename="'.$name.'.ics"');
echo $data;
?>
Then in the Wordpress theme file:
<?php
$start_date = get_post_meta($post->ID, "fc_start", true);
$c_start_date = date("M j, Y",strtotime($start_date));
$end_date = get_post_meta($post->ID, "fc_end", true);
$c_end_date = date("M j, Y",strtotime($end_date));
$start_time = get_post_meta($post->ID, "fc_start_time", true);
$end_time = get_post_meta($post->ID, "fc_end_time", true);
$ics_args['start'] = strtotime($start_date . " " . $start_time);
$ics_args['end'] = strtotime($end_date . " " . $end_time);
$ics_args['name'] = get_the_title();
$ics_args['description'] = get_the_content();
$ics_args['location'] = get_post_meta($post->ID, "location", true);
$ics_url = plugins_url('kaneko/calendarize-it-mods/ics_event.php') . "?";
foreach($ics_args as $key => $value) {
$ics_url .= "$key=$value&";
}
if($c_start_date == $c_end_date) {
echo $c_start_date;
} else {
echo $c_start_date . " - <br />" . $c_end_date;
}
?>
And finally the $ics_url
variable is getting echoed in an anchor tag like so:
<a href="<?php echo $ics_url; ?>">
I've tried changing the strtotime in the $uid
variable of the plugin to something like +5 hours
but it does not seem to work.
Any help would be greatly appreciated.
Oh and I also played around with changing the timezone in the Wordpress settings. It is currently set to UTC-5, so I thought changing it to like Chicago would help but it did not either.