Thread: Date and time functions?

  1. #1
    Registered User
    Join Date
    Jul 2002

    Question Date and time functions?

    Hello all,
    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!

  2. #2
    Registered User quagsire's Avatar
    Join Date
    Jun 2002
    #include "time.h"
    time_t timer;
    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));
    Check the structure of the tm struct. From there you will be able to extract the time (eg. tblock->tm_hour)

  3. #3
    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

  4. #4
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Visalia, CA, USA
    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.

  5. #5
    Registered User
    Join Date
    Jul 2002
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Advancing day by day until it matches a second date
    By nhubred in forum C++ Programming
    Replies: 1
    Last Post: 05-30-2009, 08:55 AM
  2. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  3. Sending an email in C program
    By Moony in forum C Programming
    Replies: 28
    Last Post: 10-19-2006, 10:42 AM
  4. Todays time and date
    By wozza in forum C Programming
    Replies: 7
    Last Post: 05-27-2002, 03:42 PM