Set Default Date and Time

How to set default date and time for text fields.
Set default date to current date and default time to current time.

@ray For date and time fields, if you set the initial value to {{moment()}} it will put in right now in your local time as the default value. The “Format String” setting is how you change how the result shows up. For times, hh:mm:ss will give you 12hr time and HH:mm:ss will give you 24hr. For dates, MM/DD/YYYY will give you 10/01/2019. Look up moment.js formatting for other options.

1 Like

If you want to display these in a Text field instead of a date/time kind, you can set the default value as {{moment().format("MM/DD/YYYY, HH:mm:ss")}} or whatever kind of format you’d like

Thanks, I’ll give this a try

Unfortunately, neither solution works. Please help me set the default value to the current date/time

Is that the form element? Try using the datetimepicker component. There the “Initial Value” field will work the way @alex-westreich described.

Yes, that’s the form element. Is there a way to set the default value for that item?

If not, I’ll use the date time picker for now.

Thanks for taking a look!

I’m sure there is a way to do it for a form component as well (if necessary via a transformer), but why bother? If the input field (or datetime picker) itself has a default value, the form will automatically use it if the user doesn’t select anything manually.

I see, that’s good to know. Thanks! for the help!