2 Replies Latest reply on Jan 2, 2019 7:31 PM by Sanford Whiteman

    Let user select time and date to store in a datetime field

    Franky Ruysschaert

      I have create a new Custom Field , and the datatype is datetime.

      I wanted to use this field to let users define the exact date and time for an appointment.


      When I drag the field on a form, I can select the Field type, but I only see a date option, and not a datetime.

      Is there an easy way to let users select the date and the time and store it in my defined datetime field?

      Or should I split this up , create a date field and a time field? And use an option list for the time input?



        • Re: Let user select time and date to store in a datetime field
          Nick Hajdin

          The easiest way to do this will be splitting up as you noted, using Select as field type and listing out the time slots as the field value options. I would create a custom field String type "Appointment Time" and provide those options to your users. This will also give you more control over when appointments are scheduled.


          If you need this information relayed to Sales you can use tokens such as {{lead.Appointment Date}} and {{lead.Appointment Time}}.

          • Re: Let user select time and date to store in a datetime field
            Sanford Whiteman

            Definitely not a fan of splitting into 2 fields on the back end. That destroys the ability to do datetime math in filters and flows... it's a net loss, and the DateTime datatype has these powers for a reason.


            Now on the front end, there's no single user expectation for a datetime picker (due to a combo of spotty browser support and different choices made by the browsers that do implement type=datetime). So the best solutions are custom JS-based widgets which allow you to predict/control the look across platforms. These all split out the date and time visually, but consolidate to a single DateTime field on form submission, which is what you want on the back end.


            A basic example using the Flatpickr widget with a Marketo form is here:


                  MktoForms2 :: DateTimePicker (flatpickr) v1.0.0


            If you like another widget better, that will work too. They all have the same concept: enhance an <input type=text> visually using dynamic elements, write to the real field under the hood.