C++ millisecond date and time into a string
Posted on 2008-06-12
Having an __int64 value representing a millisecond time since January 1, 1970, 00:00:00 GMT, how can I convert it into a string representation of format yyyyMMddHHmmssSSS (milliseconds included) in the most efficient way? I'm well aware of struct tm* t = gmtime( &time ); , but how would I be able to get the date and the milliseconds into this as well? Is there a better way then just doing a division after division to extract the values? if not, can this be made with bitwise operations somehow?
This solution is to be done with C++, and be compatible with all compilers/OSs around. Should use UTC as timezone.