SOLVED

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

Go to solution
Highlighted

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

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?

Proposals?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Level 5 - Champion Alumni

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

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}}.

View solution in original post

2 REPLIES 2
Highlighted
Level 5 - Champion Alumni

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

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}}.

View solution in original post

Highlighted
Level 10 - Community Moderator

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

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.