Frage

I have a script that generates an iCal feed from my database of dates. I finding that the script is adjusting the times for daylight saving - ie, all of the start times in the database are 21:00 but dates listed after the end of March are adjusted to 22:00...how can I stop this?...I simply want the times to show as they appear in the database and I don't want any adjustment for daylight saving or timezone (as the website is aimed at a UK audience).

mysql_select_db($database_name, $connection); // makes other mysql_ functions act on        this database
echo "BEGIN:VCALENDAR\r\n"; //some static ical headers
    echo "VERSION:2.0\r\n";
    echo "PRODID:-//www.the-guards.co.uk gig bible ical feed v1//EN\r\n";
    echo "X-WR-CALNAME:Gig Dates\r\n";
    echo "X-WR-TIMEZONE:Europe/London\r\n";
    echo "X-WR-CALDESC:Private gig diary.\r\n";

$query  = " … "; /* [SQL Query] */

$result = mysql_query($query);
define('DATE_ICAL', 'Ymd\THis\Z');
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo 
"BEGIN:VEVENT\r\n".
"UID:{$row['id']}\r\n".
"SUMMARY:{$row['location_name']}\r\n".
"DTSTART:" .date(DATE_ICAL, strtotime("{$row['starts']}"))."\r\n".
"DTEND:" .date(DATE_ICAL, strtotime("{$row['ends']}"))."\r\n".
"END:VEVENT\r\n"
;
}
echo  "END:VCALENDAR\r\n";
War es hilfreich?

Lösung

You can use this to set the timezone to a GMT+0 timezone for the runtime of your script:

date_default_timezone_set('GMT');

Then date() will not change the times anymore

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top