i have been searching the net for 3hours now on how to solve my problem about how to extract the milliseconds from an input but still found no answers. sigh! . Im trying my luck here that maybe experts have an idea about this.
the input i have is in type time_t. We know we can get the hours, minutes and seconds thru localtime call. but how about the milliseconds?
I saw ftime, gettimeofday, clock_gettime but theyre not helping me, they all return the current time.
the input i have is in type time_t. We know we can get the hours, minutes and seconds thru localtime call. but how about the milliseconds?
I don't think time_t stores milliseconds. It may be compiler dependent, but I think in most cases it only stores seconds.
If you need more accurate time measures have a look at http://www.codeguru.com/forum/showthread.php?t=291294.
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
If your using windows, you can use the COleDateTime class which uses a double to represent time from some epoch. The COleDateTime class has the function GetAsSystemTime to read the date/time into a SystemTime which holds milliseconds. Unfortunately the milliseconds are not read. This is a bug that Microsoft is aware of. However, there is a fix for this if you want to go this route by way of VariantTime.
My method will get you microseconds or even nanoseconds as it retrieves the value from the high-resolution performance calculator.
It is a better method.
Last edited by ahoodin; July 26th, 2011 at 12:43 PM.
Bookmarks