Mar 15, 2011

Use time function to get timestamp in nanoseconds on Linux


#include < time.h >

#include < stdio.h >

int GetTime()
{

   struct timespec tsp;

   clock_gettime(CLOCK_REALTIME, &tsp);   //Call clock_gettime to fill tsp

   fprintf(stdout, "time=%d.%d\n", tsp.tv_sec, tsp.tv_nsec);

   fflush(stdout);

}

1 comment:

  1. I'm not a developer, i always use the free online timestamp generator to create the unix timestamp.

    ReplyDelete