Updating the postDate field from a plugin? I think I'm almost there with this one but obviously missing something as the postDate is not updating. I have the following in an onSaveEntry event. It's saying it's successful but the postDate does not change. Ideally I want this to update whether the entry is enabled or not.

public function onSaveEntry(Event $event)
{
    $entry = $event-&gt;params['entry'];
    // set postDate from assignedDate
    if($user-&gt;admin) {
        if($entry-&gt;assignedDate &amp;&amp; $entry-&gt;assignedTimeslot) {
            $timeslot = $entry-&gt;assignedDate.' '.$entry-&gt;assignedTimeslot.'.000000';
            $params = $entry-&gt;postDate = $timeslot;
            $success = craft()-&gt;elements-&gt;saveElement($entry, $params);
        }
    }
    return $event;
}
$timeslot isn't formatted correctly to be used as the postDate. I'd create a field that takes a date and a time and then use DateTimeHelper::formatTimeForDb() to format for use as postDate.

You can't modify the postDate until after the entry has been saved - so will need to resave the entry with the newly set postDate. More info as to why you have to do this here.

craft()-&gt;on( 'entries.onSaveEntry', function( Event $event ){

  // Grab the entry from post request
  $entry = $event-&gt;params['entry'];

  // Get logged in user
  $user = craft()-&gt;userSession-&gt;getUser();

  if ( $user &amp;&amp; $user-&gt;admin ) {
    $timeSlot = $entry-&gt;getContent()-&gt;assignedTimeslot;

    // If the postDate and Timeslot don't match (stops infinite loop)
    if ( !( $entry-&gt;postDate == $timeSlot ) ) {

        // Set postDate to timeSlot date
        $entry-&gt;postDate = DateTimeHelper::formatTimeForDb( $timeSlot );

        // Resave entry
        craft()-&gt;entries-&gt;saveEntry( $entry );
    }
  }
});