Getting the Current date and time?

I need to have the current date and time from the DesktopDateTimePicker, and I find everywhere I look this code to get it:

Var currentDateTime As DateTime = DateTime.Now

But I get this error:

WinStoryCalendarEvents.butTodayEventDate.Action, line 2
Type "Integer" has no member named "Now"
Var currentDateTime As DateTime = DateTime.Now

Any suggestions how to get the Now date and time?

Update: I got it to work, there was a property set as integer… This is now the working code:

// Initialize the property with the current date and time
Var currentDateTime As DateTime = DateTime.Now

// Set the DateTimePicker to the current date and time
DateTimePickerEvents.SelectedDate = currentDateTime.Now
1 Like

The syntax is:

Now(timeZone As TimeZone = Nil) As DateTime

Not tested, at a restaurant / my meal comes…

Sorry: you do not pass a locale or a Nil. This API2 command add that…

I tested the example in the debugger, and it works fine:
Var d As DateTime = DateTime.Now break