[ back to toc ]

Getting system date in linux

Date: 2002/05/29 16:45

Q:
HI Peter
Can you tell me how to get current system time in linux and write it in a
file.I want to make a this program in C.
I want that when i run this program it takes current time from system and
write it in a file.
Please reply me asap.
Regards
*NAME-DELETED*
A:
verhas@verhaslinux:~$ cat test.c
#include <stdio.h>

main(){
FILE *fp;

fp = fopen("test.time","w");
fprintf(fp,"%d\n",time());
fclose(fp);
}
verhas@verhaslinux:~$ cc -o test test.c
verhas@verhaslinux:~$ ./test
verhas@verhaslinux:~$ cat ./test.time
1022684493
verhas@verhaslinux:~$

[ back to toc ]