Entry URIs incorrect when using entriesService->saveEntry() I'm doing an import, and saving entries into a channel with saveEntry(), but the entry's URL gets saved in the wrong format.

The URL format for the channel is: news/{postDate.year}/{slug} and I'm saving the entry with the following code:

$title = utf8_encode($article['article_language_name']);
$description = utf8_encode($article['article_description']);
$text = utf8_encode($article['article_text']);
$date = new \DateTime($article['article_start'], new \DateTimeZone('Europe/Oslo'));

$entry = new EntryModel();
$entry-&gt;sectionId = $targetSectionId;
$entry-&gt;typeId = $targetEntryType;
$entry-&gt;authorId = $targetAuthorId;
$entry-&gt;postDate = $date;
$entry-&gt;enabled = true;

$entry-&gt;getContent()-&gt;title = $title;
$entry-&gt;setContentFromPost(array(
    'leadText' =&gt; $description,
    'bodyText' =&gt; $text
));

$success = craft()-&gt;entries-&gt;saveEntry($entry);


All the URIs lack the year param in them, but that does get included if I save the entry via the CP afterwards.

What am I doing wrong? The postDate seem to be in the correct format, but maybe I'm missing something?
Ok, so the answer was quite simple: I was using the PHP DateTime object instead of Crafts DateTime.

Removed the \ on this line:

$date = new \DateTime($article['article_start'], new \DateTimeZone('Europe/Oslo'));


and everything worked perfectly.