请问:
    我用 CTime time;
         time=GetCurrentTime();得到了时间,但我想用messagebox把它显示出来,应该怎么去写代码呢?谢谢指教!

解决方案 »

  1.   

    See the sample below, just what u want :http://www.codeproject.com/datetime/dtconverter.asp
      

  2.   

    SYSTEMTIME  st;
    char time[30];
    ::GetLocalTime(&st); 
        ::wsprintf(time," %d-%d-%d ",st.wYear,st.wMonth,st.wDay);
        ::GetTimeFormat(NULL,TIME_FORCE24HOURFORMAT,&st,"HH':'mm':'ss",time,50); 
        GetDlgItem(IDC_STATIC_TIME)->SetWindowText(time); 
      

  3.   

    CTime time;
    time = CTime::GetCurrentTime();
    CString result = time.Format("%y,%b,%d,%a");
    AfxMessageBox(result);
      

  4.   

    CTime tm = CTime::GetCurrentTime();
    CString tmp_time = tm.Format("%Y-%m-%d %H:%M:%S");
    AfxMessageBox(tmp_time);
    //ex: 2002-10-23 19:20:20
      

  5.   

    CTime t = CTime::GetCurrentTime();
    CString s = t.Format("%Y-%m-%d-%H-%M-%S");
    AfxMessageBox(s);
      

  6.   

    很简单:CStirng strText = CTime::GetCurrentTime().Format("%Y/%m/%d %H:%M:%S");