Question

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?

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top