I tried to use gettimeofday
function, but it calculates the time passed since the Epoch,
and that's not what I need.
Can someone help?
I tried to use gettimeofday
function, but it calculates the time passed since the Epoch,
and that's not what I need.
Can someone help?
I think this should work for you.
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
char buffer[30];
struct timeval tv;
time_t curtime;
gettimeofday(&tv, NULL);
curtime=tv.tv_sec;
strftime(buffer,30,"%m-%d-%Y %T.",localtime(&curtime));
printf("%s%ld\n",buffer,tv.tv_usec);
return 0;
}