How can I insert time in a date field using a calculation?

  • SuperDive
    Asked on January 3, 2022 at 5:01 PM

    Hi,

    In my form, I have a date calculation based on which ticket the user purchases (widget). I would like to also insert the time here, so I can integrate my form with Google Calendar.

    The sessions are 8:00 - 9:30 PM.


    Unfortunately, your Google calendar integration only allows me to choose up to 60 minutes duration, otherwise I have to input the value based on my form. When I try to use a form field by adding a Time field to the Date Picker, I cannot properly calculate this (it defaults to 7:00PM every time).

    Please help?

  • David JotForm Support Manager
    Replied on January 3, 2022 at 10:12 PM

    Thank you for reaching out to us. Unfortunately, you cannot insert a Time field value in a Date Picker field through conditions.

    I would suggest you to use the Appointment field instead. It would integrate correctly with Google Calendar:

    1641265688 61d3ba1892605  Screenshot 10

    So the time will show up, example:

    1641265599 61d3b9bf91bdc  Screenshot 21

    You can give your own duration to this field, and set the Intervals:

    1641265511 61d3b9676370b  Screenshot 32

    And you can define the dates it should be available:

    1641265557 61d3b995bb3ba  Screenshot 43

    To set up a max number of people that can book the same time-slot, you can go to Advance settings to specify that:

    1641265839 61d3baafda537  Screenshot 54

    Let us know if you have more questions.

  • SuperDive
    Replied on January 4, 2022 at 11:50 AM

    If I use the appointment picker, is it still somehow possible to show people how many spots are left that day? That's why I liked the widget (it showed X spots remaining).

  • Lars JotForm Support
    Replied on January 4, 2022 at 2:11 PM

    Hello,

    With a bit of adjustment to the conditions and an extra date field, I was able to accomplish this:

    1641322602 61d4986a5acc6  Screenshot 10

    I added a Date Picker field for the end of the session, that we'll use in the integration, but they can both be hidden on the final form.

    1641322663 61d498a747a50  Screenshot 21

    And as you notice on them in the screenshot, I enabled the Time Field in their properties:

    1641322700 61d498ccb572c  Screenshot 32

    Your current conditions, as seen below, were picking the wrong time during the day when the Time Field is enabled.

    1641322751 61d498ff6d1c2  Screenshot 43

    To get it to pick 8PM while in New York time zone, I had to add ".0417" to the amount.

    1641323106 61d49a62e0bd7  Screenshot 54

    And then had to do that for each one, and then the Session Date gets filled correctly with the time.

    And when Session Date is filled, I add Session Date + 90 minutes (0.0625 days) to Session End.

    1641323176 61d49aa81f658  Screenshot 65

    And for the integration, I used the Session Date and Session End for the start and end time of the calendar event:

    1641323373 61d49b6ddf607  Screenshot 76

    One problem with this is if users are in other time zones, it might select another hour. As we don't have the autocorrecting features of the Appointment Field. But if your customers are in your area, that shouldn't be a problem.

    Please give this a try, and let us know if you run into any issues!

    Best regards,
    Lars