Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Use DateTime for Gravity Forms Salesforce Web-to-Lead Addon
* 1. Tell the plugin to use DateTime instead of Date for the "MyPrefix__Date_and_Time__c" field
* @param string $boolean Whether to use DateTime instead of Date (default: false)
* @param string $key The Field Name (or API Name if a custom field) used in Salesforce
* @param array $additional_info Associative array with form, entry, field, feed data
function modify_gf_salesforce_use_datetime( $boolean = false, $key = '', $additional_info = array() ) {
// Use your own Field Name or API Name below instead of the "MyPrefix__Date_and_Time__c"
// If it matches, DateTime will be used
if( $key === 'MyPrefix__Date_and_Time__c') {
return true;
return $boolean; // Otherwise, Date will be used by default
add_filter('gf_salesforce_use_datetime', 'modify_gf_salesforce_use_datetime', 10, 3 );
* 2. Change the date format (optional)
* If the date format isn't working for DateTime, you can modify it here.
* Use the format shown here for your country:
* @link
function modify_gf_salesforce_datetime_format( $format ='Y-m-d H:i:s' ) {
* Use a different format, using the Date Time Formats shown here:
* @link
return 'c';
add_filter('gravityforms/salesforce/datetime_format', 'modify_gf_salesforce_datetime_format');
Copy link

SimmoSays commented May 23, 2016

Is this a working solution to the following error?

2016-05-23 17:03:07.973458 - ERROR --> GFSalesforce::create:

Exception While Exporting Entry
There was an error exporting Entry #1145 for Form #38. Here's the error:
'2016-05-23 21:03:06' is not a valid value for the type xsd:dateTime
2016-05-23 17:03:07.983292 - DEBUG --> GFSalesforce::export_feed: Lead failed to be created/updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment