Time between two dates.

droman

Member
Licensed User
Longtime User
Is it possible to know the number of days, hours, minutes and seconds until a specific date?

Thanks!
 

droman

Member
Licensed User
Longtime User
I need more precission, day, hours, minutes and seconds.
 
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
I need more precission, day, hours, minutes and seconds.

B4X:
  Dim seconds, minutes, hours, days As Int
  Dim date1, date2, elapsed As Long
  date1 = DateTime.DateParse("02/01/2013") + DateTime.TimeParse("08:00:00")
  date2 = DateTime.DateParse("03/01/2013") + DateTime.TimeParse("00:00:01")
  elapsed = date2 - date1
  seconds = Round(elapsed / 1000)
  minutes = Floor(seconds / 60) Mod  60
  hours = Floor(seconds / 3600)
  days = Floor(hours / 24)
  hours = hours Mod 24
  seconds = seconds Mod 60
  Log(days & ", " & hours & ":" & minutes & ":" & seconds)
 
Upvote 0

droman

Member
Licensed User
Longtime User
Perfect! thanks!

:sign0098:
 
Upvote 0
Top