CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2002
    Location
    INDIA
    Posts
    135

    Some Problem with CTime (MFC)

    Hi all,


    i'm trying to get date and time using CTime class object.
    like

    int day;
    CTime tm;
    day = tm.GetDay();

    but it's giving some assertion failuer error. am i doing any mistake? please tell me what was wrong with my code? n suggest me how to get date and time using VC++ MFC.

    Thanks in advance
    -srujan

  2. #2
    Ctime curtime =CTime::GetCurrentTime();
    m_sTime.Format("%d:%d:%d",curTime.GetHour(),curTime.GetMinute(),curTime.GetSecond());
    try this

  3. #3
    Join Date
    Mar 2001
    Posts
    7
    Hi !

    To get the current time :

    1) Allocate a CTime object, as follows:
    CTime theTime;

    Note : Uninitialized CTime objects are not initialized to a valid time

    2) Call the CTime::GetCurrentTime function to get the current time from the operating system.

    theTime = CTime::GetCurrentTime();

    And then you can use GetDay();

    int iDay = theTime.GetDay();

    Hope it's help !

    comiv

  4. #4
    Join Date
    Mar 2002
    Location
    INDIA
    Posts
    135
    HI manikanna & comiv,

    thanks for your help. now i'm getting my curent time and date with your code help.

    Thank you very much

    regards
    -srujan

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