Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Program to output time down to milliseconds

Status
Not open for further replies.

aixmurderer

IS-IT--Management
Nov 28, 2000
603
NZ
Hi guys, I am a total non-entity when it comes to C programming, but I am stuck between a rock and a hard place and my gut feeling is a C program could do this for me. I need a C program which will output a time string down to milliseconds on a unix system, preferably in hhmmsscc format.

Unix lets me down as the 'date' function only goes down to seconds, I need finer control to name multiple files which are generated in the same second. I wish to call such a program whenever a script runs to generate a more accurate datestamp for renaming the file.

Any pointers to such a program would be wonderful, I have now surfed the net for days and never got close to anything which would generate this for me.
IBM Certified Confused - MQSeries
IBM Certified Flabbergasted - AIX 5 pSeries System Administration
 
have a lock in solaris man pages:
drv_hztousec (9f) and drv_usectohz (9f)

you also can help you, a tricky way

char fname[256];
long now;
int loop = 1;

while(loop){
time(&now);
sprintf(fname,"ypath.%ld.%06%d",now,loop++);
/* create here the file using creat|access|open|fopen */
if(break-condition) loop = 0;
}
 
sure, read:
sprintf(fname,"ypath.%ld.%06d",now,loop++);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top