最快捷的得到如“2003-12-24 12:36:00”格式时间办法是什么?

解决方案 »

  1.   


    CTime t=CTime::GetCurrentTime();   //取出当前时间
             int y=t.GetYear();
    int d=t.GetDay();
    int m=t.GetMonth();
    int h=t.GetHour();
    int min=t.GetMinute();
    int s=t.GetSecond(); CString yy,dd,mm,hh,mins,ss,total;
    yy.Format("%d",y);
    dd.Format("%d",d);
    mm.Format("%d",m);
    if(h<10)
        hh.Format("0%d",h);
    else
    hh.Format("%d",h);
    if(min<10)
            mins.Format("0%d",min);
    else
        mins.Format("%d",min);
    if(s<10)
        ss.Format("0%d",s);
    else
    ss.Format("%d",s);    total=yy+"-"+mm+"-"+dd+"  "+hh+":"+mins+":"+ss;total就是你的结果.
      

  2.   

    CTime::FormatCString Format( LPCTSTR pFormat ) const;
      

  3.   

    我所知道的最快捷是:
    CTime t = CTime::GetCurrentTime();
    ss=t.Format("%Y-%m-%d %H:%M:%S");
    AfxMessageBox(ss);
      

  4.   

    SYSTEMTIME time;
    GetLocalTime(&time);
    char buffer[100];
    sprintf(buffer,"%d-%d-%d %d-%d-%d",time.wYear,time.wMonth,
             time.wDay,time.wHour,time.wMinute,time.wSecond);
    buffer即为所求。
      

  5.   

    CTime tm = CTime::GetCurrentTime();
        CString str = tm.Format("%Y-%m-%d %H:%M:%d");
      

  6.   

    不好意思,第二句是
    CString str = tm.Format("%Y-%m-%d %H:%M:%S");
      

  7.   

    CTime::Format()好好研究一下,很简单的
      

  8.   

    CTime t=CTime::GetCurrentTime();
    CString csTime;
    csTime.Format("%d-%d-%d %d:%d:%d",t.GetYear(),t.GetMonth(),t.GetDay(),t.GetHour(),t.GetMinute(),t.GetSecond());
      

  9.   

    char sztime[128];
    struct tm t;
    _getsystime(&t);
    sprintf(sztime,
            "%d-%02d-%02d %02d:%02d:%02d",
            t.tm_year+1900,t.tm_mon,t.tm_mday,t.tm_hour,t.tm_min,t.tm_sec
            );