N Nitin Joshi Active Member Licensed User Longtime User Dec 20, 2020 #1 I am using below code to message set on time. Messages shows time as 14:00:00 however i want to show time as 2:00 PM. Please suggest. Time Value: MsgboxAsync ("On Time: " & DateTime.Time(DateTime.TimeParse(14 & ":" & 0 & ":" & 0)),"")
I am using below code to message set on time. Messages shows time as 14:00:00 however i want to show time as 2:00 PM. Please suggest. Time Value: MsgboxAsync ("On Time: " & DateTime.Time(DateTime.TimeParse(14 & ":" & 0 & ":" & 0)),"")
M Mahares Expert Licensed User Longtime User Dec 20, 2020 #2 Nitin Joshi said: i want to show time as 2:00 PM. Please suggest. Click to expand... Something like this: B4X: Dim s As String =14 & ":" & 0 & ":" & 0 Dim l As Long =DateTime.TimeParse(s) DateTime.Timeformat ="hh:mm:ss a" Log(DateTime.Time(l)) '02:00:00 PM remove the seconds from the format if you do not want them Upvote 0
Nitin Joshi said: i want to show time as 2:00 PM. Please suggest. Click to expand... Something like this: B4X: Dim s As String =14 & ":" & 0 & ":" & 0 Dim l As Long =DateTime.TimeParse(s) DateTime.Timeformat ="hh:mm:ss a" Log(DateTime.Time(l)) '02:00:00 PM remove the seconds from the format if you do not want them
N Nitin Joshi Active Member Licensed User Longtime User Dec 21, 2020 #3 Thanks, appreciated! Upvote 0
N Nitin Joshi Active Member Licensed User Longtime User Dec 21, 2020 #4 How to bring back time format to default format? Upvote 0
Andrew (Digitwell) Well-Known Member Licensed User Longtime User Dec 21, 2020 #5 DateTime.Timeformat is a string so you can save it before the change and restore it afterwards. eg. B4X: private originaltimeformat as string = datetime.timeformat DateTime.Timeformat ="hh:mm:ss a" Log(DateTime.Time(l)) '02:00:00 PM datetime.timeformat = originaltimeformat Upvote 0
DateTime.Timeformat is a string so you can save it before the change and restore it afterwards. eg. B4X: private originaltimeformat as string = datetime.timeformat DateTime.Timeformat ="hh:mm:ss a" Log(DateTime.Time(l)) '02:00:00 PM datetime.timeformat = originaltimeformat
N Nitin Joshi Active Member Licensed User Longtime User Dec 21, 2020 #6 Perfect! it worked, thank you. Upvote 0
N Nitin Joshi Active Member Licensed User Longtime User Dec 21, 2020 #7 One more thing, if i want 24 hour time format then below syntax is correct? B4X: DateTime.Timeformat="hh:mm" Aslo, how to parse time when I set time format as "hh:mm a"? Upvote 0
One more thing, if i want 24 hour time format then below syntax is correct? B4X: DateTime.Timeformat="hh:mm" Aslo, how to parse time when I set time format as "hh:mm a"?
Andrew (Digitwell) Well-Known Member Licensed User Longtime User Dec 21, 2020 #8 There is a link in the description to the format methods. The one for time format links to this page https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html Upvote 0
There is a link in the description to the format methods. The one for time format links to this page https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html