iOS Question B4I Date Picker incorrect date

touchsquid

Active Member
Licensed User
Longtime User
My Code::
            DateTime.DateFormat="yyyy-mm-dd"
            DateTime.timeformat = "hh:mm"
            Dim MyDate As String = "2022-04-18"
            Dim Mytime As String = "10:00"
            Dim MyTicks As Long =  DateTime.DateTimeParse(MyDate, Mytime)
            Log(DateTime.Date(MyTicks)) 'shows 2022-04-18 10:00 so ticks are correct
            RaceDate.Ticks = MyTicks'ThisRace.StartDate)    'racedate is the DatePicker'

The above code causes the datepicker to read: January 18, 2022 10:00 AM

See screenshot.

Is this a bug in Datepicker, or have I done something wrong?
 

Attachments

  • B4I DatePicker.png
    B4I DatePicker.png
    54.8 KB · Views: 129

touchsquid

Active Member
Licensed User
Longtime User
The problem is in DateTimeParse

My Code::
    DateTime.DateFormat="yyyy-mm-dd"
    DateTime.timeformat = "HH:mm"
    Dim MyDate As String = "2022-04-15"
    Dim Mytime As String = "13:55"
    Log (MyDate & " " & Mytime)
    Dim MyTicks As Long =  DateTime.DateTimeParse(MyDate, Mytime)
    Log(DateTime.Date(MyTicks))
    Log(DateTime.time(MyTicks))

The log:
2022-04-15 13:55
2022-59-15
13:59

I tried it in B4A and got the same result. I expected it to work.

Am I misunderstanding how the functions work?
 
Upvote 0

touchsquid

Active Member
Licensed User
Longtime User
Eureka!

Changing date format tpo "yyyy-MM-dd" produces correct results.
 
Upvote 0
Top