So, I was recently working with a Web-To-Lead form in Salesforce and realized that all my values were being inserted into the new Lead record except for one field. Yes, it was a DateTime field – a custom one. I figured out that that it must be the format issue, so, I began trying multiple formats.
While looking for different formats online, I came to find that some DateTime formats that worked for others in their Web-To-Lead forms, didn’t work for me at all. In fact, many had faced the same issue. Some formats worked for some while didn’t work for others.
Instead of trying various formats, I started looking further into the problem and soon came to understand that DateTime field formats in Salesforce’s Web-To-Lead depend on the Locale and Time Zone set in Salesforce settings. In my case, the locale and time zone was of Germany, while I was trying US DateTime formats (that worked for the people with US timezone in Salesforce).
So, if you want to find out the correct format for your Web-To-Lead form, follow the steps below:
- Go to Salesforce instance in which you created the Web-To-Lead form
- Go to Settings and then Language and Time Zone
- Check your Locale and Timezone
- Based on your Locale, get the correct DateTime format from official Salesforce documentation
Here are a few examples of correct DateTime formats.
Locale | DateTime Format |
German (Germany) | 28.01.2008, 16:30 |
English (Canada) | 2008-01-28, 4:30 p.m. |
English (United Kingdom) | 28/01/2008, 16:30 |
English (Pakistan) | 28/01/2008, 4:30 pm |
English (United States) | 1/28/2008, 4:30 PM |
I hope this will help you getting your DateTime format right in your Web-To-Lead form.
Also, check out: