Android Question Datepicker with time

samikinikar

Member
Licensed User
Longtime User
Can someone please help to get the time along with date with anotherdatepicker ?

B4X:
Private delduedate As AnotherDatePicker

dim newdate as long
DateTime.DateFormat ="yyyy-MM-dd HH:mm:ss"
newdate=delduedate.date

log(DateUtils.TicksTostring(newdate)   'prints  2018-11-30 00:00:00

I tried the above code, but each time, the time is 00:00:00, how to get the current time, along with date ?
 

mangojack

Expert
Licensed User
Longtime User
If you just want to include current time (when user picks the date) ..

B4X:
DateTime.DateFormat ="yyyy-MM-dd"
DateTime.TimeFormat= "HH:mm:ss"    'unsure if needed .. as this might be default format
Dim newdate As Long = delduedate.date  
Dim newtime As String = DateTime.Time(DateTime.Now)
  
Log(DateTime.Date(newdate) & " " & newtime)
    'OR
Log($"${DateTime.Date(newdate)} ${newtime}"$)
 
Upvote 0
Top