how to get the current date and time in C++ ?

November 29, 2010 at 05:09:51
Specs: Windows 7
In my program I have to create an output file that prints the results of the round along with the date and time. How to get the current date and time in C++ in a readable format.

See More: how to get the current date and time in C++ ?

Report •

November 29, 2010 at 07:20:50
The easiest way is probably to use std::strftime(). It's a bit too complicated to explain how to use it here but you can look it up in your compiler's help manual.

Report •

March 22, 2011 at 00:07:25
its really simple
just type time n select it right clivk it u will get help and there see example its really easy dude!!!

Report •

March 22, 2011 at 17:01:11
I'm learning C++ too. In one of the things I've made I have the date and time. If you have Windows XP and up you can type in :

system("echo %time%");
cout << "\n";
system("echo %date%");

echo is the dos command for cout or printf() depending on which one you normally use. I use it though when I use environmental variables.

The only problem is that the format is probably going to be in a 24 hour clock.

Report •

Related Solutions

April 7, 2011 at 22:51:53
But I didnt get the Output........

Report •

Ask Question