setTimezone($tz); $dateObj->setDate($year, $month, $day); $dateObj->setTime($hour, $minute, $second); // How much wrong will ->format("U") be if I do it now, due to DST changes? // Only needed until PHP Bug #51051 delivers a better method $unix_offset1 = $tz->getOffset($dateObj); $unix_offset2 = $tz->getOffset(new DateTime()); $unix_correction = $unix_offset1 - $unix_offset2; $unixTimestamp = $dateObj->format("U") - $unix_correction; return $unixTimestamp; } $fp = fopen('talks.csv', 'r'); $xml = new SimpleXMLElement(''); $first_row = true; $sessions = $xml->addChild('sessions'); while(($row = fgetcsv($fp)) !== FALSE) { if($first_row) { // my titles are in here, skip! $first_row = false; continue; } $session = false; $time = false; $session = $sessions->addChild('session'); $second = 0; $time = explode(':',$row[1]); $hour = $time[0]; $minute = $time[1]; // making the assumption of a british format date! (dd/mm/yyyy) $date = explode('/',$row[0]); $day = $date[0]; $month = $date[1]; $year = $date[2]; // hardcoding DPC's timezone $tz = 'Europe/Amsterdam'; $timestamp = UnixtimeForTimeInTimezone($tz, $year, $month, $day, $hour, $minute, $second); $session->addChild('session_start', $timestamp); $session->addChild('session_type', $row[3]); if($row[2]) { $session->addChild('session_track', $row[2]); } $session->addChild('session_speaker', htmlentities($row[4])); $session->addChild('session_title', htmlentities($row[5])); $session->addChild('session_desc', htmlentities($row[6])); } file_put_contents('talks.xml',$xml->asXML());