0

I'm trying to know the timestamp when I receive a message. I should check if it has been N seconds of receiving the last message. I'm using time_t. I take the current time like this: time (& myTime);

how can I check if they spent more than N seconds?

Is there a way to know the number of seconds (timestamp) of a total time_t?

Safari
  • 11,437
  • 24
  • 91
  • 191

1 Answers1

2

You ask the "number of seconds" of a time_t. This would be absolute time. You'd want probably then want to format it using localtime() or some such function in hour/minute/second, day/month/year form.

If you want to know the time since a previous event, you should simply save the time_t from that event and then use a statement like if (difftime(thisevent_time, lastevent_time) > max_seconds) to handle it.

Colin D Bennett
  • 11,294
  • 5
  • 49
  • 66