hi all,

i want to generate a timestamp with year,date,month,day,hours,min,seconds,milliseconds.
in my code i generated a time integer with the help of time().
with that integer can i generate timestamp with milliseconds.

sample code:

int len;  
	time_t mytime;
        presentTimeStamp = 1999999950;//this value is return from time()
	mytime = presentTimeStamp;
	 struct tm *mytm;  
        mytm=localtime(&mytime);  
   
     	strftime(timeArray,50,"%a, %d %b %Y %H:%M:%S",mytm); 


//for milli seconds 
	char timearray[20]; 
	int ms = mytime % 1000;
	sprintf(timearray, ":%03d", ms);
     
      //	printf("%s\n",timearray);  
	strcat(timeArray,timearray);

is it right??(i mean milli seconds calculation)


i am using linux(fc6)

thanks
kriscbe

Recommended Answers

All 2 Replies

Try gettimeofday()

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.