does anybody know how to get the current time & date settings ?
I've tried using ctime(3), but i can't get it.
thanks in advance,
Kurt J. Lanza
time_t now = time(NULL);
char *text = ctime(&now);
printf("Time is: %s", text);
Well, actually, given that he didn't also say "I've tried using time(2)"Quote:>A little more information as to how you "can't get it" would surely
>get you a more informative response. Your post is the equivalent of
>"my car won't start".
The original poster should try using "time()" to get a "time_t" value
representing the current date/time, and then using the various routines
in the "ctime" man page to convert that to other formats as desired.
Then again, given that "ctime()" takes an argument, I would have
expected it to have been obvious that you can't use it to *get* the
current time and date settings, you can only use it to format a setting
you've *already gotten* into a string....
Reply, or follow up, but don't do both, please.
I hope i can drop my question about Linux shell programming here?
I'm writing a script in bash to find files. I'm using the slocate
programm, which is being runned every hour using a cron job, to create
Now i want to know how long it is ago that the database has been
recreated. Zo i need to check the date and time from that file and
compare it with the current date and time. I know there must be easy to
do but i can't find the trick to do it.
Maikel van Gorkom
Sent via Deja.com http://www.deja.com/
Before you buy.