I want to find out the value in ticks of a time after midnight with something like the following code:
When hour = 4 above the timestring = "03:00 on 27/10/2013" where it should be "04:00 on 27/10/2013".
To try to explain this I ran this code
and the log I get is:
Time is 01:00 on 27/10/2013
Time is 01:00 on 27/10/2013
Time is 02:00 on 27/10/2013
Time is 03:00 on 27/10/2013
Time is 04:00 on 27/10/2013
So adding 2 hours in TicksPerHour to midnight still gives 01:00 which surely is not right?
Ta.
B4X:
midNight = DateTime.DateParse(DateTime.Date(DateTime.now))
hoursInTicks = hour*datetime.TicksPerHour ' hour is integer value after midnight, eg 4
finalTime = midnight + hoursInTicks
timeString = DateTime.Time(finalTime) & " on " & DateTime.date(finalTime)
When hour = 4 above the timestring = "03:00 on 27/10/2013" where it should be "04:00 on 27/10/2013".
To try to explain this I ran this code
B4X:
dim midnight, ltime as long
midNight = DateTime.DateParse(DateTime.Date(DateTime.now))
for i = 1 to 5
ltime = midnight + datetime.TicksPerHour * i
log("Time is " & DateTime.Time(ltime) & " on " & DateTime.date(ltime)
next
and the log I get is:
Time is 01:00 on 27/10/2013
Time is 01:00 on 27/10/2013
Time is 02:00 on 27/10/2013
Time is 03:00 on 27/10/2013
Time is 04:00 on 27/10/2013
So adding 2 hours in TicksPerHour to midnight still gives 01:00 which surely is not right?
Ta.