Mixed up time from DateTime

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Everyone,

I get strange numbers from using DateTime.

B4X:
intTheCurrentDateTime = DateTime.Now
intHour = DateTime.GetHour(intTheCurrentDateTime) 
intMinute = DateTime.GetMinute(intTheCurrentDateTime)
intSeconds = DateTime.GetSecond(intTheCurrentDateTime)

ToastMessageShow("Hours: " & intHour, False)
ToastMessageShow("Minutes: " & intMinute, False)

The toast give me 19 when the real time was 13. Looks like it went ahead 6 hours.

If I do the same with minutes, it goes ahead 19 minutes.

Is this a bug? Am I using DateTime the wrong way?

Thanks.
 

rleiman

Well-Known Member
Licensed User
Longtime User
Thanks.

It was an Int instead of Long.

:D

Two questions:
- did you set the time correctly on the device or emulator.
- did you Dim intTheCurrentDateTime As Int ?

it must be
Dim intTheCurrentDateTime As Long !

Best regards.

 
Upvote 0
Top