Get the current date/time from a DesktopDateTimePicker

I’m trying to get the current date/time from a DesktopDateTimePicker when my app is up and running. But I don’t know how to activate the DesktopDateTimePicker.
Active? I tried this and Xojo didn’t like it.
Enabled? It’s enabled (and graphical and displays the seconds hand.)
Refresh? I had a timer firing every one second and (in the timer’s action) I was refreshing the datetimepicker, but this didn’t work.
Ask it nicely? The best solution I’ve come up with thus far.
Does anyone know how to solve this mystery? Thank you!

You get and set the value of the DesktopDateTimePicker via it’s SelectedDate property. You control how it looks via DisplayMode, DisplaySeconds, GraphicalDisplay and HourMode.

What are you trying to achieve?

Are you looking for SelectedDate?

If what you want is the actual current date and time, use DateTime.Now.

If you want the currently-selected DateTime of the picker, read its properties as Tim said.

1 Like

Note to self…

Timer1 > Action > mydatetimeobject.SelectedDate = DateTime.Now
Button1 > Pressed > msgbox mydatetimeobject.SelectedDate.ToString


Var currentthings As Date = DateTime.Now
Var message As String = currentthings.LongDate + " " + currentthings.ShortTime
msgbox message

BTW, don’t forget to thank the lovely people that helped you. They did a good job and you certainly couldn’t have worked this out without them, so make sure that you use an exclamation mark at the end of it to give it more meaning.

Thank you lovely people that helped me!