Getting Format from CTime AM/PM

Hello there,

I'm new in MFC and still learning. I'm trying to get a correct format from the CTime::GetCurrentTime() and was not able to get the AM or PM. After keep on searching, i don't have any more clues on how to do this. Currently with this syntax taken from the previous recommendation from here, i would able to have the format to get like this.. but no AM/PM..

Can anyone please help?

CTime today = CTime::GetCurrentTime();
CString stime;
stime.Format("%02d/%02d/%04d %2d:%02d:%02d",today.GetDay(),today.GetMonth(),today.GetYear(),today.GetHour() %12,today.GetMinute(),today.GetSecond());

Results as below
12/02/2008 3:29:59


  • I believe GetHour() gives you an hour in military time (been a while). Did a quick 12 hour offset calc to determine am or pm.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion