Is there a Date and Time field available in Gravity Forms? I need to send data in this format: YYYY-MM-DD HH:MM:SS to an external API. I guess i then need a field where both date and time can be set.
Hi Morgan. Take a look at the gform_replace_merge_tags filter, specifically example 9:
That will give you a merge tag you can use to output a date in whatever format you need (you will need to modify this line:
$local_date = date_i18n( 'Y-m-d', $local_timestamp, true );
and change Y-m-d to whatever format gives you YYYY-MM-DD HH:MM:SS. I think it would be this:
$local_date = date_i18n( 'Y-m-d H:i:s', $local_timestamp, true );
If you need that date/time stored in the entry, so you can map it to your API using the Webhooks add-on or something like that, you will need a slightly different approach to populate a field with a date/time in that format.
Hi Chris,
I also need a Date/Time Picker. I tried following your instructions regarding the merge tags but did not succeed. Could you elaborate on this approach? I inserted the snippet into the common.php and added the time format as you mentioned above. Unfortunately it didn’t work
Thanks and best regards
The snippet should go into your theme functions.php file. You should not modify any Gravity Forms core file. I’m sorry I did not mention that earlier.
The code does not create a date/time picker though. It gives you a merge tag you an use in your notification to show the date/time in a specific format
Thank you for your answer.
I really need a date / timer picker though. Do you know any workaround?
I don’t know of one currently. There used to be one here:
https://gravityextend.com/gravity-forms-add-on/date-time-picker/
But that appears to be gone, and I could not find it on github.
Hi, I was looking for something similar, came across this plugin which I have working with gravity forms https://wordpress.org/plugins/date-time-picker-field/
Thanks for that @wizontheweb!