Set default time in Date component retool

Hello guys. Hope you can help me. I have a readonly date component and I want it's value to be 7 days from now at 23:59:59 (example, 2022-01-27T23:59:59.000), but the default value is 00:00:00.
I tried to use the Date Time component and set the hour to 23:59:59 using

{{ new Date(parseFloat(,59,59,0) }}

but it only works if I click in the component, which I don't want to because it's a readonly component with no need for alteration. If I don't click, it displays just a number string a causes an error in the requisition. Any tips about how should I do it?

{{ new Date (new Date(parseFloat((,59,59,0)).toString() }}

Don't know if this is the best way but it works.

1 Like

Hi @Gabrielasil, welcome to the community!

Why not use moment.js on this instead of parsing and adding that one heck of a millis conversion?
You can use this (attributing to your locale time):

{{ moment().add(7, 'd').hour(23).minute(59).second(59) }}

If utc matters, you can use this:

{{ moment.utc().add(7, 'd').hour(23).minute(59).second(59).format("MMM D, YYYY H:mm") }}

The reason format is included in this utc consideration is because Date Time component would add your locale timezone and your hour/minute will be different than intended.



Thank you so much for you help. It worked and looks so much better now.