-
Time
Hello,
i want to print out the Systemtime:
m_sTime.Format("%d:%d:%d", curTime.GetHour(), curTime.GetMinute(), curTime.GetSecond());
That will print out: 3:4:9 for Example.
But ... I want it looks like: 03:04:09.
How do I format the String to get the expected Result?
Any help' s welcome,
thx
-
m_sTime.Format("%2d:%2d:%2d", curTime.GetHour(), curTime.GetMinute(), curTime.GetSecond());
should work...
-
Blank
Hello,
at first thank you for your Reply. If I format the String like you wrote I will get Blanks in my String not the Zero Number. The Result will look as follows: 3: 4: 9
Have any other Idea?
Many thanks.
-
Strange! But you can try to get CTime::Format() to work. (Or is it CTimeSpan?)
-
Fill up Spaces
Hello,
better using: m_sTime.Format("%02d:%02d:%02d", curTime.GetHour(), curTime.GetMinute(), curTime.GetSecond());
Thanks for your help,
Myvar
-
time.h
/*This is the code give you the time
*/
#include <iostream>
#include <time.h>
#include <ctime>
using namespace std;
int main(){
system("cls");
time_t T;
time(&T);
cout<<ctime(&T)<<endl;
system("pause");
exit(0);
}
-
tom: even easier would be:
cout << ctime(time(NULL)) << endl;
-
Nice
Nice Code up there.
I do not write a Console - Application.
Thx anyway,
Myvar
-
Code:
m_sTime = ctime(time(NULL));
The benefit of doing it this way is that this is GUARANTEED to be a specific format, for example the time is always in the same position in the returned string.