Please help with current time in c++

This is a discussion on Please help with current time in c++ within the C++ Programming forums, part of the General Programming Boards category; Hi every one i have been doing a project i did all what i had to do everything is fine ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    26

    Please help with current time in c++

    Hi every one i have been doing a project i did all what i had to
    do everything is fine and final part is that i need to show the
    current date and time, i wonted to ask that if i need the time_t or ctime please help
    Code:
    #include<time.h>
              #include<iostream.h>
    do i need any thing else for the time and the date
    --------------------------------------------------------------------------------
    C++ Is cool

  2. #2
    Registered User
    Join Date
    Oct 2002
    Posts
    13
    Hi!
    i would do the following:
    Code:
    #include <ctime>
    using namespace std;
    char cur_date[9];
    char cur_time[9];
    _strdate(cur_date);
    _strtime(cur_time);
    cout << "Time: "<<cur_time<<endl <<"Date: "<<cur_date;

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by teneniel
    Hi!
    i would do the following:
    Code:
    #include <ctime>
    using namespace std;
    char cur_date[9];
    char cur_time[9];
    _strdate(cur_date);
    _strtime(cur_time);
    cout << "Time: "<<cur_time<<endl <<"Date: "<<cur_date;
    Then you would be using non-standard functions. If you want to suggest these, fine, but at least point out in your post that they are non-standard, and that they may not work on all compilers.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Journey time prog 1 minute wrong
    By mike_g in forum C Programming
    Replies: 4
    Last Post: 10-12-2006, 04:41 AM
  2. Military Time Functions
    By BB18 in forum C Programming
    Replies: 6
    Last Post: 10-10-2004, 02:57 PM
  3. Killing someones grandparents
    By nickname_changed in forum A Brief History of Cprogramming.com
    Replies: 37
    Last Post: 09-07-2003, 08:56 AM
  4. Is this really true or it's just science fiction?
    By Nutshell in forum A Brief History of Cprogramming.com
    Replies: 145
    Last Post: 04-09-2002, 07:17 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