I created a simply code of getting the current date. Now, I noticed that after compling the result is 3012013. But, what I want is 30/01/2013. How do I do this...
Here is the code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
#include <ctime>
usingnamespace std;
int main( )
{
// current date based on current system
time_t now = time(0);
tm *ltm = localtime(&now);
cout << ltm->tm_mday << 01 + ltm->tm_mon << 1900 + ltm->tm_year << endl;
}
coder777 (2516) Jan 30, 2013 at 4:58pm
But, what I want is 30/01/2013. How do I do this...
Like so:
cout << ltm->tm_mday << '/' << 01 + ltm->tm_mon << '/' << 1900 + ltm->tm_year << endl;
And one more thing. How do I loop it that the day will be change to the next day.
What do you mean? loop until tm_mday changes?