Skip to content

Instantly share code, notes, and snippets.

@a-am
Last active December 14, 2015 09:39
Show Gist options
  • Save a-am/5066800 to your computer and use it in GitHub Desktop.
Save a-am/5066800 to your computer and use it in GitHub Desktop.
<?
require($_SERVER["DOCUMENT_ROOT"]."/monkcms.php");
header('Content-type: application/json');
$outarray;
$nodes;
$json;
//doesn't get you a event that is currently happening we need to use yesterday day with startdate and enable past to account for events currently happening.
$yesterday = date('n/j/y', mktime(0, 0, 0, date("m") , date("d") - 1, date("Y")));
$today = date();
$string = getContent(
"event",
"display:list",
"enablepast:yes",
"startdate:".$yesterday,
"find_category:live-service",
"recurring:yes",
"repeatevent:yes",
"show:__title__",
"show:||",
"show:__eventstart format='F j, Y G:i:s'__",
"show:||",
"show:__eventstartTwo format='F j, Y'__",
"show:||",
"show:__eventend format='G:i:s'__",
"show:||",
"show:__website__",
"show:~~",
"noecho",
"nocache"
);
$prearray = explode("~~",$string);
for ($i=0; $i <count($prearray)-1; $i++) {
$outarray[$i] = explode("||",$prearray[$i]);
}
$i = 0;
foreach ($outarray as $key => $value) {
$timeZone = "America/New_York";
$stdate = $value[1];
$endate = $value[2]." ".$value[3];
$dateTimeS = new DateTime($stdate, new DateTimeZone($timeZone)); //test time for specific time zone.
$dateTimeE = new DateTime($endate, new DateTimeZone($timeZone));
//$dateTimeS->setTimeZone(new DateTimeZone($timeZone));
//$dateTimeE->setTimeZone(new DateTimeZone($timeZone));
//$dateTimeS->format('F j, Y G:i:s O'); //format = January 15 2011 13:37:21 +200
//$dateTimeE->format('F j, Y G:i:s O');
$start = strtotime($value[0]);
$end = strtotime($value[2]." ".$value[3]);
/*echo("------------------\r\n");
echo(strtotime("today")."\r\n");
echo($end."\r\n");*/
if($end > strtotime("today")){
$nodes[$i] = array(
id => "id".strval($i),
title => $value[0],
date => array(
start => $dateTimeS->format('F j, Y G:i:s O'),
end => $dateTimeE->format('F j, Y G:i:s O')
),
url => $value[4]
);
$i++;
}
}
$json = json_encode($nodes);
echo $json;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment