Difference between revisions of "Microsecond time"
Jump to navigation
Jump to search
(Created page with "I needed this one on Solaris to display microseconds (µseconds): time_ms.c <source lang="c"> #include <sys/time.h> main() { struct timeval tv; gettimeofday(&tv, (voi...") |
(No difference)
|
Latest revision as of 13:05, 27 March 2018
I needed this one on Solaris to display microseconds (µseconds):
time_ms.c
#include <sys/time.h>
main()
{
struct timeval tv;
gettimeofday(&tv, (void*)0);
// Print time with milliseconds and decimal separator
// printf("%d.%03d\n", tv.tv_sec, tv.tv_usec/1000);
// Print time with microseconds without decimal separator
printf("%d%06d\n", tv.tv_sec, tv.tv_usec);
}
Compile:
gcc time_ms.c -o time_ms
Credits: https://superuser.com/questions/178330/milliseconds-from-solaris-command-line