I need some help with time

This is a discussion on I need some help with time within the C++ Programming forums, part of the General Programming Boards category; I need a very very simple bit of code to just cout the time,day,month,year. I am not picky about the ...

  1. #1
    Registered User sswaters's Avatar
    Join Date
    Oct 2005
    Posts
    18

    I need some help with time

    I need a very very simple bit of code to just cout the time,day,month,year. I am not picky about the format(ie dd,mm,yyyy) its just time in C++ just confuses the hell out of me and i cant seem to find a very small and simple bit of code.
    And sorry if there is a faq item for this i didnt see one
    King of the overly complicated code

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    see the functions in time.h
    Code:
    #include <ctime>
    #include <iostream>
    
    
    int main()
    {
       time_t now = time(0);
       struct tm* tm = localtime(&now);
       std::cout << asctime(tm) << std::endl;
    
       return 0;
    }
    Last edited by Ancient Dragon; 10-24-2005 at 06:12 AM.

  3. #3
    Registered User sswaters's Avatar
    Join Date
    Oct 2005
    Posts
    18
    thanks
    thats all i needed
    King of the overly complicated code

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to get current time
    By tsubasa in forum C Programming
    Replies: 3
    Last Post: 05-01-2009, 03:03 AM
  2. Replies: 11
    Last Post: 03-29-2009, 01:27 PM
  3. Help with assignment!
    By RVDFan85 in forum C++ Programming
    Replies: 12
    Last Post: 12-03-2006, 12:46 AM
  4. calculating user time and time elapsed
    By Neildadon in forum C++ Programming
    Replies: 0
    Last Post: 02-10-2003, 06:00 PM
  5. time class
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 12-11-2001, 10:12 PM

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