Android Question Wrong date with DateTime.now

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi All,

From reading the threads on the forum this is a long standing issue.
The following code should show today's date but before 10:00AM I get yesterdays date. My time zone is +10, but I thought "DateTime.SetTimeZone(0)" sorted this issue. Any help would be greatly appreciated.

Regards Roger

Sub Date_click
DateTime.SetTimeZone(0)
Dim now As Long
now = DateTime.now
Msgbox("The date is: " & DateTime.Date(now) & CRLF & _
"The time is: " & DateTime.time(now), "")
End Sub​
 

TomA

Active Member
Licensed User
Longtime User
I haven't played with this but from the description of that function, it sounds to me like it sets the application time zoned so setting it to zero would give you GMT. Since you are at +10, the date will show a day behind until you are 10 hours into the day. I suspect you should not use SetTimeZone if you want the current date and time on the current device.
 
Upvote 0
Top