none
How TO get The Current Time in Vc++ 6.0

    Question

  • Wat s the Code And Method to get the current time and date of my system and to display it in edit box
    Wednesday, June 01, 2011 9:19 AM

Answers

  •           im using...

              SYSTEMTIME st;

              GetSystemTime(&st);

              m_ct.Format("The Time is %d : %d : %d", st);

     

             is it enough to display it in message box..

     

    • Marked as answer by Shankar RJ Friday, June 03, 2011 11:07 AM
    Wednesday, June 01, 2011 9:53 AM
  • Thank u I got it Thanks to Every One...

    this the Code of my program i caculate milli seconds too..

     // Jus copy and Paste the code in your program to get the time and display it in edit box

      DWORD dwEnd = GetTickCount();   // start Of milli seconds

      CTime ct=CTime::GetCurrentTime();

      char *str=new char[10];

      UpdateData(true);
      m_ct.Format("%d:%d:%d",ct.GetHour(),ct.GetMinute(),ct.GetSecond());  //m_ct is edit box Var .,
      UpdateData(false);

      DWORD dwEnd = GetTickCount(); // End Of milli seconds
       
      UpdateData(true);

       m_time = dwEnd - dwStart; //To Calculate MIlliseconds difference m_time is another edit box Var .,

       UpdateData(false);


    • Marked as answer by Shankar RJ Thursday, June 02, 2011 7:37 AM
    Thursday, June 02, 2011 5:15 AM

All replies

  • You can use time function. The example on the MSDN page shows how to print the time in various formats using printf. You can set it in your edit box in a similar fashion.

    - Shoaib.

    Wednesday, June 01, 2011 9:42 AM
  • Perhaps this will help: http://stackoverflow.com/questions/997946/get-current-time-and-date

    You can set an edit box text by using SetWindowText function.


    Cosmin Pirvu
    Wednesday, June 01, 2011 9:43 AM
  • You can use the following code.

     

     

    SYSTEMTIME st;
    
    GetSystemTime(&st);

     

     

    You can also check with the following code

    http://weseetips.com/tag/getsystemtime/

     


    Thanks and Regards Selvam http://www15.brinkster.com/selvamselvam/
    Wednesday, June 01, 2011 9:45 AM
  •  thank u...

             SYSTEMTIME st;

             GetSystemTime(&st);

             
             m_ct.Format("The Time is %d", st);

     

    is it nough to display it in message box..

     

     

     

      (     i have to display it in text box..my text box Id s m_ct)

    Wednesday, June 01, 2011 9:50 AM
  •  thank u...

             SYSTEMTIME st;

             GetSystemTime(&st);

             
             m_ct.Format("The Time is %d", st);

     

    is it enough to display it in message box..

     

      (     i have to display it in text box..my text box Id s m_ct)

    Wednesday, June 01, 2011 9:51 AM
  •           im using...

              SYSTEMTIME st;

              GetSystemTime(&st);

              m_ct.Format("The Time is %d : %d : %d", st);

     

             is it enough to display it in message box..

     

    • Marked as answer by Shankar RJ Friday, June 03, 2011 11:07 AM
    Wednesday, June 01, 2011 9:53 AM
  • Your original question asked for the current time and date. The MSDN example given on the time function page contains a comprehensive example to help you in that.

    Here is a slightly modified code snippet, based on the MSDN example given in the above page, for specifically what you need (assuming 'm_ct' is a CString variable defined in your code).

    time_t ltime;
    time( &ltime );
    TCHAR* pTimeStr = _tctime(&ltime);
    CString strTime = pTimeStr;
    strTime.TrimRight();
    m_ct.Format(_T("The Time is %s"), (LPCTSTR)strTime);
    - Shoaib.
    Wednesday, June 01, 2011 12:24 PM
  • Thank u I got it Thanks to Every One...

    this the Code of my program i caculate milli seconds too..

     // Jus copy and Paste the code in your program to get the time and display it in edit box

      DWORD dwEnd = GetTickCount();   // start Of milli seconds

      CTime ct=CTime::GetCurrentTime();

      char *str=new char[10];

      UpdateData(true);
      m_ct.Format("%d:%d:%d",ct.GetHour(),ct.GetMinute(),ct.GetSecond());  //m_ct is edit box Var .,
      UpdateData(false);

      DWORD dwEnd = GetTickCount(); // End Of milli seconds
       
      UpdateData(true);

       m_time = dwEnd - dwStart; //To Calculate MIlliseconds difference m_time is another edit box Var .,

       UpdateData(false);


    • Marked as answer by Shankar RJ Thursday, June 02, 2011 7:37 AM
    Thursday, June 02, 2011 5:15 AM