Thread: displaying date and time

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    88

    displaying date and time

    Is there any possible way to display the date and time that my program was executed?

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Code:
    #include <stdio.h>
    #include <time.h>
    
    int main(void)
    {
       time_t now = time(NULL);
       puts(asctime(localtime(&now)));
       /* [edit]
       puts(ctime(&now));
       [/edit] */
       return 0;
    }
    Last edited by Dave_Sinkula; 09-08-2003 at 11:45 AM.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Wannabe Coding God
    Join Date
    Mar 2003
    Posts
    259
    if you want to save it for later you can always trow it down in a file aswell.
    They say that if you play a Windows Install CD backwords, you hear satanic messages. That's nothing; play it forward and it installs Windows.

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. Displaying time and date of files
    By wozza in forum C Programming
    Replies: 3
    Last Post: 05-25-2002, 11:53 AM