Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format Time

Status
Not open for further replies.

Camouflage

Programmer
Apr 23, 2002
13
AU
I am using the timer code from c++ in 21 days, which is basically the following:

CTime curTime = CTime::GetCurrentTime();

m_sTime.Format("%d:%d:%d", curTime.GetHour(),
curTime.GetMinute(),
curTime.GetSecond());

But if it is 3minutes & 9seconds past 9, I would like it to read 09:03:09 instead of 9:3:9.

Thanks
 
Try using the CTime format function which returns a CString in the 0 padded format

eg
m_sTime = CTime::GetCurrentTime().Format("%H:%M:%S" );

or padding out the numbers in the CString format

eg
m_sTime.Format("%02d:%02d:%02d\n",curTime.GetHour(),curTime.GetMinute(),curTime.GetSecond());
 
Thanks for taking the time to answer that, but this is all to hard for me, lmao.
I've thrown c++ out the window and grabbed a copy of VB - it's much easier on my stress levels :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top