#include <sys/time.h>
#include <time.h>
#include <stdio.h>
int main(void)
{
char buffer[30];
struct timeval tv;
time_t curtime;
gettimeofday(&tv, NULL);
printf("%ld/n",tv.tv_sec);
printf("%ld/n",tv.tv_usec);
curtime=tv.tv_sec;
strftime(buffer,30,"%m-%d-%Y %T.",localtime(&curtime));
printf("%s%ld/n",buffer,tv.tv_usec);
return 0;
}
#include <time.h>
#include <stdio.h>
int main(void)
{
char buffer[30];
struct timeval tv;
time_t curtime;
gettimeofday(&tv, NULL);
printf("%ld/n",tv.tv_sec);
printf("%ld/n",tv.tv_usec);
curtime=tv.tv_sec;
strftime(buffer,30,"%m-%d-%Y %T.",localtime(&curtime));
printf("%s%ld/n",buffer,tv.tv_usec);
return 0;
}