Problem with Time library

Hi Guys

I'm having difficulty understanding how to use the Time library. In particular... I have a variable "previous_read_millis" which records the last time I read the sensors. I then want to do some further logic based on the hour and minutes of the time recorded as per the following line of code...

if(hour(previous_read_millis) = 8)

This didn't produce the desired result, so I tried outputting a test sketch to the serial monitor to see what was happening...

Serial.println (previousMillis); Serial.print ("hour "); Serial.println (hour(previousMillis)); Serial.print ("minute "); Serial.println (minute(previousMillis)); Serial.print ("second "); Serial.println (second(previousMillis));

This code returned the following output

9181 hour 2 minute 33 second 1 10200 hour 2 minute 50 second 0

but surely this is wrong... I was expecting...

hour 0 minute 0 second 10

What am I doing wrong...?

Thanks Ned

(10200 - 9181) / 60 = 16.9833333

16.9833333 looks suspiciously like the number of minutes between the two values. Try dividing previousMillis by 1000.

BINGO!!!

Now why didn't I spot that....?

Thanks

Ned :-[