How to perspective Date Time Input - default todays date, fixed time

I have Date Time Inputs on a perspective view. I want to bind the .value to ‘today’s’ date with a fixed time, to show that way on loading. These are shift start and stop times. They both, (date and time) should be changeable, if the user wanted to select a different day/shift. I would just like to default this way on page load.

There is Tag historical data bound to them as the start and end date.

I can use now() to get current date, but then it gives me the current time too…
the dateFormat I found in documentation:
dateFormat(now(), ‘yyyy-MM-dd 00:00:00’) //Returns the current date, but forces the time to 00:00:00.

is not working. I’m getting an error and no date populated in the input.
I’m wondering if there is another way, something doing wrong? Thanks much!

So you want to turn now() into just date?

In an expression:

setTime(now(),6,0,0)

Will return now with the time set to 6:00:00 AM obviously you can replace the hour, minutes, and/or seconds with a property or tag value of your choosing.

In scripting

system.date.setTime(system.date.now(),6,0,0)
3 Likes

yes,

and the concatonate a fixed time ideally

Yup, that was it, seems like kind of an obvious one to miss, thanks. One minor kicker, is I need it set that way on startup, but not the value bound to it, but I got that done in the Events, OnStartup script. Thanks again.