Default value just for time in DateTime component

Hello everyone,

In the DateTime component is there any way to leave the date blank and add a default value just for the time?

Thanks for the help!

Hey @douglas.palermo, welcome to the community :hugs:

You can use the Time component for that. Would that work for your use-case?

Hello @minijohn! Thanks for the answer :grin:

Yes, that would be my last alternative. But if possible, it would be better to keep the DateTime component because it fits better in the interface.

I don't see how you could do that currently. You could invalidate the date selector by changing it's value to - for example but a user would still be able to click it and set a time.

You could also hide the date selector via css, but still, once the user clicks on the input it will popup the date selector as the first step.

I would use the Time component, it's literally the same input just without the date part :stuck_out_tongue:

@minijohn I think I didn't explain it right.
I want the user to change the date, and to have the option to change the time as well, but I want to bring the time filled by default as 2 pm and the date blank by default.

Got ya,

something like this?

Yes! Something like this, but these way the user can't add the date.

Hey @douglas.palermo, You might be able to add an 'on change' event handler to the component that sets a temporary state variable to true. Then you could use a ternary in the 'Date Format' input to set the format based on that state variable.

This would only allow you to leave the date blank before the calendar menu has been opened for the first time.

Alternatively, you could use a Date Component and a Time Component next to one another as @minijohn suggested!

I hope that helps with your use case :slightly_smiling_face:

1 Like

Awesome! Thanks for your help @everett_smith @minijohn :smiley: :+1:

1 Like

nice approach @everett_smith :mechanical_arm:

1 Like