T trueboss323 Active Member Licensed User Longtime User Feb 22, 2015 #1 Here is what I am using to try to save the current date and time: B4X: 'Saving currentdatelbl.text = DateTime.now StateManager.SetSetting("CurrentDate",currentdatalbl.Text) 'Loading currentdatelbl.Text = StateManager.GetSetting("CurrentDate") But when I try to load it, I get something like "1424645748955" , which I have no idea what it means. How can I change the format so it appears as mm/dd/yyy hh:mm:ss ?
Here is what I am using to try to save the current date and time: B4X: 'Saving currentdatelbl.text = DateTime.now StateManager.SetSetting("CurrentDate",currentdatalbl.Text) 'Loading currentdatelbl.Text = StateManager.GetSetting("CurrentDate") But when I try to load it, I get something like "1424645748955" , which I have no idea what it means. How can I change the format so it appears as mm/dd/yyy hh:mm:ss ?
mangojack Expert Licensed User Longtime User Feb 22, 2015 #2 1424645748955 is the Date and Time measured in Ticks. Search for DateFormat .. Upvote 0
T trueboss323 Active Member Licensed User Longtime User Feb 22, 2015 #3 Thanks, I did not realize that before. I set my format as DateTime.TimeFormat = "dd/MM/yyy KK:mm:ss a" Now I'm not sure how to use it. Is this the correct way to put it? : B4X: 'Saving DateTime.TimeFormat = "dd/MM/yyy KK:mm:ss a" currentdatelbl.text = DateTime.now StateManager.SetSetting("CurrentDate",currentdatalbl.Text) 'Loading DateTime.TimeFormat = "dd/MM/yyy KK:mm:ss a" currentdatelbl.Text = StateManager.GetSetting("CurrentDate") Upvote 0
Thanks, I did not realize that before. I set my format as DateTime.TimeFormat = "dd/MM/yyy KK:mm:ss a" Now I'm not sure how to use it. Is this the correct way to put it? : B4X: 'Saving DateTime.TimeFormat = "dd/MM/yyy KK:mm:ss a" currentdatelbl.text = DateTime.now StateManager.SetSetting("CurrentDate",currentdatalbl.Text) 'Loading DateTime.TimeFormat = "dd/MM/yyy KK:mm:ss a" currentdatelbl.Text = StateManager.GetSetting("CurrentDate")
B buras3 Active Member Licensed User Longtime User Feb 23, 2015 #4 uselessly you can use B4X: DateTime.Date(DateTime.now) & " " &DateTime.time(DateTime.now) or use this function B4X: ConvertToDate(DateTime.now) Sub ConvertToDate(sec As Long) As String Dim TempStr As String TempStr=NumberFormat(DateTime.GetDayOfMonth(sec),2,0) TempStr=TempStr & "/" & NumberFormat(DateTime.GetMonth(sec),2,0) TempStr=TempStr & "/" & DateTime.GetYear(sec) TempStr=TempStr & " " & NumberFormat(DateTime.GetHour(sec),2,0) TempStr=TempStr & ":" & NumberFormat(DateTime.GetMinute(sec),2,0) Return TempStr End Sub Upvote 0
uselessly you can use B4X: DateTime.Date(DateTime.now) & " " &DateTime.time(DateTime.now) or use this function B4X: ConvertToDate(DateTime.now) Sub ConvertToDate(sec As Long) As String Dim TempStr As String TempStr=NumberFormat(DateTime.GetDayOfMonth(sec),2,0) TempStr=TempStr & "/" & NumberFormat(DateTime.GetMonth(sec),2,0) TempStr=TempStr & "/" & DateTime.GetYear(sec) TempStr=TempStr & " " & NumberFormat(DateTime.GetHour(sec),2,0) TempStr=TempStr & ":" & NumberFormat(DateTime.GetMinute(sec),2,0) Return TempStr End Sub
ivan.tellez Active Member Licensed User Longtime User Feb 23, 2015 #5 buras3 said: or use this function Click to expand... Whats the point in reinventing the wheel? Java provides functions to format dates. They are really flexyble, and much more efficient than doing it manually. I posted the string formats in the forums a couple times. The correct answer to this problem has been aswered in here, you can use the search function to find it. Last edited: Feb 23, 2015 Upvote 0
buras3 said: or use this function Click to expand... Whats the point in reinventing the wheel? Java provides functions to format dates. They are really flexyble, and much more efficient than doing it manually. I posted the string formats in the forums a couple times. The correct answer to this problem has been aswered in here, you can use the search function to find it.