time.h and today's date

This is a discussion on time.h and today's date within the C Programming forums, part of the General Programming Boards category; Hi, How would i go about finding the current date and 'saving' it to a variable(string or int?)? I have ...

  1. #1
    !NSAN!TY
    Guest

    time.h and today's date

    Hi,
    How would i go about finding the current date and 'saving' it to a variable(string or int?)?

    I have no experience whatsoever in using time.h

    Basically i'd like to know:
    What variables i need to declare.
    What command do i use to get the current date(dd/mm/yyyy)
    And how everything works

    Thanks in advance!

  2. #2
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    Code:
    #include <stdio.h>
    #include <time.h>
    
    int main()
    {
    	time_t hold_time;
      	hold_time=time(NULL);
    	printf("%s", ctime(&hold_time));
    	return 0;
    }
    - edit -
    Additional information:
    http://www.rt.com/man/time.2.html
    Last edited by Shadow; 10-16-2002 at 06:22 PM.
    The world is waiting. I must leave you now.

  3. #3
    !NSAN!TY
    Guest
    umm ok that helps a little but how do i print the current date in the format dd/month/yyyy .. eg: 12 Jan 2002 ?

  4. #4
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    You can find info about time.h _all over_ this message board, try the search feature.
    The ever knowledgable Google may have a few things for you.

    > And how everything works
    Try here.
    The world is waiting. I must leave you now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. Output Text File Name by Today's Date
    By jbayne in forum C++ Programming
    Replies: 1
    Last Post: 07-09-2007, 08:09 AM
  3. Todays time and date
    By wozza in forum C Programming
    Replies: 7
    Last Post: 05-27-2002, 03:42 PM
  4. Extracting and formatting today's date
    By Chewie in forum C Programming
    Replies: 4
    Last Post: 08-16-2001, 07:45 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21