Mehrzad238 Active Member Jul 16, 2020 #1 can anyone help me to add day,month and year to this sub: B4X: Sub ConvertMillisecondsToString(t As Long) As String Dim hours, minutes, seconds As Int hours = t / DateTime.TicksPerHour minutes = (t Mod DateTime.TicksPerHour) / DateTime.TicksPerMinute seconds = (t Mod DateTime.TicksPerMinute) / DateTime.TicksPerSecond Return $"$1.0{hours}:$2.0{minutes}:$2.0{seconds}"$ End Sub
can anyone help me to add day,month and year to this sub: B4X: Sub ConvertMillisecondsToString(t As Long) As String Dim hours, minutes, seconds As Int hours = t / DateTime.TicksPerHour minutes = (t Mod DateTime.TicksPerHour) / DateTime.TicksPerMinute seconds = (t Mod DateTime.TicksPerMinute) / DateTime.TicksPerSecond Return $"$1.0{hours}:$2.0{minutes}:$2.0{seconds}"$ End Sub
DonManfred Expert Licensed User Longtime User Jul 16, 2020 #2 B4X: Dim today As Long = DateTime.Now Dim twodays As Long = DateTime.Add(today,0,0,2) ' Add 0 Years, 0 Months, 2 Days Log(ConvertMillisecondsToString(twodays)) Upvote 0
B4X: Dim today As Long = DateTime.Now Dim twodays As Long = DateTime.Add(today,0,0,2) ' Add 0 Years, 0 Months, 2 Days Log(ConvertMillisecondsToString(twodays))
Erel B4X founder Staff member Licensed User Longtime User Jul 16, 2020 #4 DateFormat is relevant if you want to convert a specific instance of time to a date string. Assuming that the question is about periods then the correct way to do it is with DateUtils.PeriodBetween. However there isn't enough context in the question to really answer it. Upvote 0
DateFormat is relevant if you want to convert a specific instance of time to a date string. Assuming that the question is about periods then the correct way to do it is with DateUtils.PeriodBetween. However there isn't enough context in the question to really answer it.
E emexes Expert Licensed User Longtime User Jul 16, 2020 #5 Erel said: However there isn't enough context in the question to really answer it. Click to expand... No argument there ✌ Upvote 0
Erel said: However there isn't enough context in the question to really answer it. Click to expand... No argument there ✌