VisualCpp.org Collection of Visual C++ Stuffs

1Jul/090

How to to calculate the future date from number of seconds available from now?

Naveen responded with this very useful piece of code using CTimeSpan and CTime MFC classes.

// Get Time in second for one day.
CTimeSpan sPan(0,0,0, 86400 );// 1 day
// Get current time
CTime CurTime = CTime::GetCurrentTime();
// add time span to current time
CurTime += sPan;
// calculate and show your new date
CString csTime = CurTime.Format(_T("%A, %B %d, %Y"));
AfxMessageBox( csTime );

Filed under: General, MFC Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


Trackbacks are disabled.