CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Posts
    15

    How to get system date&time by no using MFC (CTime, etc)?

    Does anybody know C/C++ function to obtain system date and time by not using MFC? (which allow achieve same result as CTime::GetCurrentTime())


  2. #2
    Join Date
    May 1999
    Posts
    667

    Re: How to get system date&time by no using MFC (CTime, etc)?

    This should do what you need
    #include <time.h>


    {
    time_t t;
    t = time(NULL);
    tm *timeinfo;
    timeinfo = gmtime(&t);

    //timeinfo.tm_sec; /*int seconds after the minute - [0,59] */
    //timeinfo.tm_min; /*int minutes after the hour - [0,59] */
    //timeinfo.tm_hour; /*int hours since midnight - [0,23] */
    //timeinfo.tm_mday; /*int day of the month - [1,31] */
    //timeinfo.tm_mon; /*int months since January - [0,11] */
    //timeinfo.tm_year; /*int years since 1900 */
    //timeinfo.tm_wday; /*int days since Sunday - [0,6] */
    //timeinfo.tm_yday; /*int days since January 1 - [0,365] */
    //timeinfo.tm_isdst; /*int daylight savings time flag */


    }

    HTH,
    Chris


  3. #3
    Join Date
    May 1999
    Posts
    5

    Re: How to get system date&time by no using MFC (CTime, etc)?

    If you are in windows You can use ::GetSystemTime()

    Ramanan


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured