Date and time functions?
I have a general question. I am in the process of writing a program that opens a specific file at midnight every night. My question is what time/date function do I need to use, and where can I find information on how to format the date/time so the program will run correctly?
Any help here is appreciated!
Check the structure of the tm struct. From there you will be able to extract the time (eg. tblock->tm_hour)
struct tm *tblock;
/* gets time of day */
timer = time(NULL);
/* converts date/time to a structure */
tblock = localtime(&timer);
printf("Local time is: %s", asctime(tblock));
you can use the program scheduler that comes with Windows too. If you don't want to do that, just make a program that remains in the background until midnight then it comes to the foreground, but of course you would have to add it to the startup thing in your start menu, or mess around with msconfig. The easiest way would be with time.h as the last person suggested
I think having the program run in the background until midnight would actually be easier. You'll still need to do the timer thing. But since I don't know what OS your are using I can't really very well tell you that the windows specific way is the best.
I'm running on a W2K machine (server), and I need this program to open an ASP page every night at midnight. The asp page contains code that I need to run on the server.