Thread: Getting system Date

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    36

    Getting system Date

    I was looking in the FAQ's but the topic was pretty unclear. I want to know how to get the date from the system. Can anyone tell me the specific or recommended function to use? I want it in the mm/dd/yyyy format.

  2. #2
    Banned
    Join Date
    Jun 2005
    Posts
    594
    http://www.codeproject.com/datetime/datetimedisc.asp

    this might be of some use, if you dont feel liek reading a
    windows specific function would be GetSystemTime()

    do a google search im sure you can prolly acheive something
    with that, or maybe time_t

  3. #3
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Here are some functions to deal with time, and formatting it in various ways (from the standard <ctime> header): http://cppreference.com/stddate/

    You could also just bring it flowers and ask really nicely.

    Cheers
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  4. #4
    Registered User
    Join Date
    Sep 2004
    Posts
    36
    That site is kinda iffy. So do i just say, GetSystemTime() and use the time.h library?


    Will this work?

    example:
    Code:
    #include<iostream> 
    #include<time.h>
    #include<string.h>
    usign namespace std;
    
    int main()
    {
    string Time;
    
    Time=GetSystemTime();
    
    cout<<Time;
    
    cin.get();
    
    return 0;
    }

  5. #5
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Something to start from. Jostle the format specifier a little. Perhaps "%m/%d/%Y".
    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.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. casting the system exstracted date into seperate ints
    By bazzano in forum C Programming
    Replies: 1
    Last Post: 08-30-2005, 12:17 AM
  2. calculate age from date
    By bazzano in forum C Programming
    Replies: 1
    Last Post: 08-22-2005, 08:57 AM
  3. bad system date
    By Silvercord in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 04-30-2003, 08:29 AM
  4. reading the system date
    By Alicia in forum C++ Programming
    Replies: 5
    Last Post: 02-13-2002, 03:18 PM
  5. System Date
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 08-28-2001, 06:03 PM