diff --git a/airtime_mvc/application/common/WidgetHelper.php b/airtime_mvc/application/common/WidgetHelper.php index d22727ad9..8be23e200 100644 --- a/airtime_mvc/application/common/WidgetHelper.php +++ b/airtime_mvc/application/common/WidgetHelper.php @@ -127,6 +127,16 @@ class WidgetHelper "ALL", $showQueryDateRangeEnd->format("Y-m-d H:i:s")); + // Convert each start and end time string to DateTime objects + // so we can get a real timestamp. The timestamps will be used + // to convert into javascript Date objects. + foreach($shows as &$show) { + $dtStarts = new DateTime($show["starts"], new DateTimeZone("UTC")); + $show["starts_timestamp"] = $dtStarts->getTimestamp(); + + $dtEnds = new DateTime($show["ends"], new DateTimeZone("UTC")); + $show["ends_timestamp"] = $dtEnds->getTimestamp(); + } $result["shows"] = $shows; // XSS exploit prevention diff --git a/airtime_mvc/application/views/scripts/embed/weekly-program.phtml b/airtime_mvc/application/views/scripts/embed/weekly-program.phtml index 872afc849..911cd4b87 100644 --- a/airtime_mvc/application/views/scripts/embed/weekly-program.phtml +++ b/airtime_mvc/application/views/scripts/embed/weekly-program.phtml @@ -40,8 +40,10 @@ // First we have to create a Date object out of the show time in UTC. // Then we can format the string in the client's local timezone. - var start_date = new Date(value.starts + " UTC"); - var end_date = new Date(value.ends + " UTC"); + // NOTE: we have to multiply the timestamp by 1000 because in PHP + // the timestamps are in seconds and are in milliseconds in javascript. + var start_date = new Date(value.starts_timestamp*1000); + var end_date = new Date(value.ends_timestamp*1000); // This variable is used to identify which schedule_data object (which day of the week) // we should assign the show to.