I need to pass from microseconds (saved inside a unsigned long long int
variable) to its representation as hours, minutes, seconds, milliseconds, that is:
from 47072349659 to 13:04:32.350
I found this conversion from milliseconds, but I don't seem to manage to make it work in my case. Maybe the problem is that the number is too long to be stored in certain variable type? I'm using unsigned long long int
for input time and tried int, long, unsigned long long int for outputs.
Here is my C++ code:
unsigned long long int timestamp;
long milliseconds = (long) (timestamp / 1000000) % 1000;
long seconds = (long) ((timestamp / (1000)) % 60);
long minutes = (long) ((timestamp / (60000)) % 60);
long hours = (long) ((timestamp / (3600000)) % 24);