Hakanunver Member Licensed User Longtime User Sep 20, 2017 #1 I wait 0 as result but see 2 hour difference why ? B4X: Dim lo As Long = DateTime.Now - DateTime.TimeParse(DateTime.Time(DateTime.Now)) Log(DateTime.Time(lo))
I wait 0 as result but see 2 hour difference why ? B4X: Dim lo As Long = DateTime.Now - DateTime.TimeParse(DateTime.Time(DateTime.Now)) Log(DateTime.Time(lo))
Misterbates Active Member Licensed User Sep 20, 2017 #2 It's probably to do with .timezoneoffset Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Sep 21, 2017 #3 DateTime.Time converts a ticks value to a string. Ticks value = Number of milliseconds since 1/1/1970 00:00 UTC. You cannot use DateTime.Time to convert a "duration" to a string. 1. Use DateUtils.PeriodBetween or PeriodBetweenInDays to correctly calculate the difference between two dates. 2. Convert the period to string with PeriodToString: https://www.b4x.com/android/forum/threads/convert-dateperiod-to-string.51046/#post-319385 This code assumes that the period is smaller than a day. Add a day field if needed. Upvote 0
DateTime.Time converts a ticks value to a string. Ticks value = Number of milliseconds since 1/1/1970 00:00 UTC. You cannot use DateTime.Time to convert a "duration" to a string. 1. Use DateUtils.PeriodBetween or PeriodBetweenInDays to correctly calculate the difference between two dates. 2. Convert the period to string with PeriodToString: https://www.b4x.com/android/forum/threads/convert-dateperiod-to-string.51046/#post-319385 This code assumes that the period is smaller than a day. Add a day field if needed.