AnsweredAssumed Answered

Time zone offset is affecting data in Logic Hooks

Question asked by Tim Fleck on Jan 21, 2015
Latest reply on Jan 23, 2015 by Rolustech Rolustech
I'm absolutely new to writing logic hooks and am certain there is a simple method to fix what I've been struggling with for days.  If I were to show you how many pages I've bookmarked you'd think I was crazy.

I have a datetime field called start_datetime_c within the Contacts module.  When a new meeting is created I want that field to carry over to the Meetings module date_start field.

So far, I have managed to get the field from Contacts and successfully move it to the field within Meetings.  However, there appears to be a time-zone offset which is causing some odd issues.  At my location we are -5 hours.

Here is an example of what is happening.  If Contact field (datetime) is  01-01-15 22:20:00 when I attempt to send it to the Meeting field it turns into 01-01-15 17:20:00.

I am sure there must be an easier method, but as I'm just learning I can't seem to find it!


class copyDate {


function fromContact(&$bean, $event, $arguments)
 
      {


       $meeting_date = $bean->date_start;



      if($bean->parent_type == 'Contacts' || $bean->date_start == '') {

        require_once('modules/Contacts/Contact.php');

        $contact_bean = new Contact();

        $contact_bean->retrieve($bean->parent_id);


        $cdate = $contact_bean->start_datetime_c;

        $cmonth = substr($cdate,0,2);

        $cday = substr($cdate,3,2);

        $cyear = substr($cdate,6,4);

        $chour = substr($cdate,11,2) + 5;
        $cmin = substr($cdate,14,2);

        $campm = substr($cdate,16,2);

        $csec = '00';
        $cfull = $cyear . "-" . $cmonth . "-" . $cday . " " . $chour . ":" . $cmin . ":" . $csec;


       }


$bean->debug1_c = $chour;
$bean->date_start = $cfull;


}

}

?>

Outcomes