SugarCRM, cForms and PHP Date Format
02 Nov 2009Something that has been plaguing my SugarCRM SOAP API implementation: inserting dates into the Leads module.
Just as in any other module, we have at least one date field. In this case, an “Expected Start Date” field for various fee-for-service inquiries is the culprit. Our original insert code for this field looked like this:
array(“name” => ‘expected_start_date_c’,”value” => $POSTdataClean['cf2_field_18']),
This didn’t work though because the date that’s coming in from cForms is of the format MM/DD/YYYY. What Sugar expects though is, “YYYY-MM-DD H:M:S.” So if you are going to insert a date into Sugar via the SOAP API, and you want it to work, you will want to use the following code:
array(“name” => ‘start_date_c’,”value” => date(‘Y-m-d H:i:s’, strtotime($POSTdataClean['cf2_field_18']))),
If you’re looking for a deeper explanation, check out the PHP manual for strtotime and date.
{ cForms, Date Format, PHP, SugarCRM }
