ctime only need to measure up to the secunds..
Posted on 2004-10-14
I am using ctime to get time values when files were created, but the times come measured in millisecunds and i want them to be measured only in secunds . Is that possible to do? here is my code
char *cp; /* to hold address of time */
cp = ctime(&timeval); /* convert time to string */
/* string looks like */
/* Mon Feb 4 00:46:40 EST 1991 */
/* 0123456789012345. */
printf("%-15.12s", cp+4 ); /* pick 12 chars from pos 4 */
the reason why i want only secunds is because i am using the time values to compare them and i display them by the most recent but in case of a tie i use file's name to order. But since the time is measured and compared in millisecunds i never get to have ties and since i display only in secunds i never tend to order by file's name and the user thinks that there are ties and looks the files are not ordered. Could be it that possible to measure the time in secunds or i guess i should make it as a string and then compare ?
Any help is greatly appriciated...