|
-
Nov 15th, 2001, 05:48 AM
#1
Thread Starter
Member
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
-
Nov 15th, 2001, 07:39 AM
#2
m_sTime.Format("%2d:%2d:%2d", curTime.GetHour(), curTime.GetMinute(), curTime.GetSecond());
should work...
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 15th, 2001, 12:09 PM
#3
Thread Starter
Member
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.
-
Nov 15th, 2001, 01:28 PM
#4
Strange! But you can try to get CTime::Format() to work. (Or is it CTimeSpan?)
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 15th, 2001, 02:07 PM
#5
Thread Starter
Member
Fill up Spaces
Hello,
better using: m_sTime.Format("%02d:%02d:%02d", curTime.GetHour(), curTime.GetMinute(), curTime.GetSecond());
Thanks for your help,
Myvar
-
Nov 17th, 2001, 11:27 AM
#6
Fanatic Member
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);
}

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Nov 17th, 2001, 02:14 PM
#7
tom: even easier would be:
cout << ctime(time(NULL)) << endl;
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 19th, 2001, 12:02 PM
#8
Thread Starter
Member
Nice
Nice Code up there.
I do not write a Console - Application.
Thx anyway,
Myvar
-
Nov 19th, 2001, 12:40 PM
#9
Monday Morning Lunatic
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.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|