I'm using this time library to access the properties of unix timestamps like hours / minutes / etc. What I want to do is get the current time, and an estimated arrival time, and find the difference between them in minutes.

Here's my code: (My estimated time is coming from an API as an INT)

time_t timeEstimated = timeInt;
time_t timeNow = now();

But how do I find the difference between these two timestamps in minutes? I'd like to try and avoid all of the conditionals / math that would come with converting to hours / minutes / seconds / dates and subtracting each component if possible.

1 Answer 1


Unix timestamps are just a count of seconds since a standard origin (1970.0 UTC), thus a simple subtraction, followed by a conversion from seconds to minutes:

float minutes_remaining = (timeEstimated - timeNow) / 60.0;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.