Click here to Skip to main content
15,917,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have to log the system time to my app log file but I am not able to format it and I dont know the proper format specifier for CTime datatype. I just used "%c" format specifier it gives some junk as result.


CString str;

m_testTime = CTime::GetCurrentTime();

str.Format(_T("%c"),m_testTime);   // not working fine
LOG(LOG_DEBUG, _T("\nSystem time :") + str);

m_nRunNumber = 10;                      //Below part working fine
str.Format(_T("%d"), mvData.m_nRunNumber);
LOG(LOG_DEBUG, _T("\nRun number: ") + str);


Pls help with this

[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 14-Mar-11 4:22am
v2

Have a look at this link[^]. Has a lot of different format parameters. :)
 
Share this answer
 
There is an article which should help here: Format Date and Time As Per User's Locale Settings[^]
I think "%x" is probably what you are looking for...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900