现在我要已经知道了第一个时间的字符串:
t1="031101123023"
也知道了一个时间间隔字符串(分钟),
dt=3
我在算出dt后的时间字符串
t2=??
我想把t1及dt转成CTime进行相加,然后再转成CString,可是CString怎么才可以转成CTime??
t1="031101123023"
也知道了一个时间间隔字符串(分钟),
dt=3
我在算出dt后的时间字符串
t2=??
我想把t1及dt转成CTime进行相加,然后再转成CString,可是CString怎么才可以转成CTime??
// 10:15 PM March 19, 1999
CString s = t.Format( "%A, %B %d, %Y" );
CTime time2 = time1; // Copy constructor.
CTime time3( osBinaryTime ); // CTime from C run-time time
CTime time4( 1999, 3, 19, 22, 15, 0 ); // 10:15PM March 19, 1999
CTimeSpan dt;
dt=3*60;
t2=t1+dt;CString buffer;
buffer.Format.("%Y-%m-%d- %H:%M:%S");
AfxMessageBox(buffer);
CString buffer;
buffer=t2.Format("%Y-%m-%d- %H:%M:%S");
AfxMessageBox(buffer);
把"031107126305"转成CTime呀??
buffer="20031107182805";
int nYear=atoi(buffer.Left(4));
int nMonth=atoi(buffer.Mid(4,2));
int nDay=atoi(buffer.Mid(6,2));
int nHour=atoi(buffer.Mid(8,2));
int nMin=atoi(buffer.Mid(10,2));
int nSec=atoi(buffer.Right(2)); CTime t1( nYear, nMonth, nDay, nHour, nMin, nSec, -1 ); CTime t2;
CTimeSpan dt;
dt=3*60;
t2=t1+dt;
buffer=t2.Format("%Y-%m-%d %H:%M:%S");
AfxMessageBox(buffer);
strCString="2003-10-27 6:24:37"; //CString--->COleDateTime
COleVariant vtime(strCString);
vtime.ChangeType(VT_DATE);
COleDateTime time4=vtime;
COleDateTime time1(1977,4,16,2,2,2); //COleDataTime--->CTime
SYSTEMTIME systime;
VariantTimeToSystemTime(time1, &systime);
CTime tm(systime);
祝你成功!
它们的返回值均为int类型,我们可以用CString中的format函数进行转换