Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Gravity Forms Function/Hook to Calculate Endtime/Enddate WordPress


I am looking for a way to dynamically populate a gravity forms time field using a hook that adds a predetermined number of hours to a starttime selected by the user filling out the form.

For example, if a user selects a 4 (number field) and then selects a start time of 6:30 than the end time is dynamically populated to be 10:30.

What I am ultimately looking for is a function for the functions.php file that will accurately create an endtime and an associated parameter to be placed in the 'allow this field to be dynamically populated' of a time-box on gravity forms

Additionally, I would want a function for the end date that, if the event goes past midnight. Then the enddate = startdate +1. This would also ultimately be a parameter for a datebox on a gravity forms to accompany the end time function

So if a user selects a 4 hour trip to start at 10:00pm then the end time would be 2:00am and the end date would be the next day.

This is based on the dynamic population ability of gravity forms

and is being used to select the endtime for an event ( ) based on a set event duration.

Answers (5)


Hai Bui answers:

So, in the form, the user would only fill start time and start date, they don't need to see or fill the end date and end time, is that correct? You only want to populate the end date and end time for Events Calendar Pro? If that is the case, I can help you do that.
Let me know.

Kyle comments:

That's exactly what I am looking for. The user is selecting a 'service' that has an hour amount tied to it, and then picking when the service starts. The end time is only so it can be properly submitted to The Events Calendar Pro

Hai Bui comments:


shapiustakis answers:

20% off red satin Chinese wedding service hi bride wedding dress - $119.00 :


Arnav Joy answers:

can you show me the form where you have integrated this ?

Kyle comments:

I exported a basic version of the gravity form

Although the link posted above contains much more complete code for the time aspect the requested code pertains to


Rashad Aliyev answers:

I offer my solution for you!


Daniel Yoen answers:

try this :

Kyle comments:

This link is in the question description...