Forum Home
Press F1
 
Thread ID: 13612 2001-12-09 22:23:00 Getting the date and time in C Guest (0) Press F1
Post ID Timestamp Content User
27142 2001-12-09 22:23:00 Does anyone know how to get the date and time in C and then print it out to the screen? Guest (0)
27143 2001-12-10 13:45:00 I haven't tried it but K&R says the functions are declared in time.h Guest (0)
27144 2001-12-10 20:18:00 #include<time.h>
#include<stdio.h>

int main(void)
{
time_t timer;

timer=time(NULL);
printf('The current time is %s\n',asctime(localtime(&timer)));
return 0;
}
Guest (0)
1