我想问一下,在vc中怎么把时间以标准格式显示出来?还有,我又一个算法,它关于时间动态调整参数的,也就是要把当前时间换算成一个值,根据这个值调整参数,怎么做?第三个问题,我自己写了一个程序,想调用CTime类中的函数方法,要怎么做啊?谢谢!

解决方案 »

  1.   

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

  2.   

    COleDateTime time;
    ....
    CString str = time.Format("%Y-%m-%d %H:%M:%S");
      

  3.   

    1.用CString Format( LPCTSTR pFormat ) const;将它格式成你想要的
    具体见MSDN的
    CTime::Format 

    strftime
    2.CTime::GetTime 
      得到的时间为1970-01-01 0:0:0 到该时间的秒数
    The time function returns the number of seconds elapsed since midnight (00:00:00), January 1, 1970, coordinated universal time, according to the system clock. The return value is stored in the location given by timer. This parameter may be NULL, in which case the return value is not stored.
    3.CTime类中的方法的调用.可先定义一个CTime的变量,然后调用