I had problems with setting an existing DateTime object to an exact Unix timestamp using modify("@$timestamp"), which seems to always be relative. So I wrote this function, which does the trick:
<?php
function set_time(DateTime $dt, $timestamp)
{
$tzo = new DateTimeZone($dt->getTimezone()->getName());
$new_dt = new DateTime("@$timestamp", new DateTimeZone('UTC'));
$new_dt->setTimezone($tzo);
$dt->setDate($new_dt->format('Y'), $new_dt->format('m'), $new_dt->format('d'));
$dt->setTime($new_dt->format('H'), $new_dt->format('i'), $new_dt->format('s'));
}
?>