Time in C++


Time from C language
1. how to get current time.
2. convert in local time and string format.
3. standard string format time.

#include <ctime> std::string gettime() { static bool btime=false; time_t rawtime; struct tm * timeinfo; char buffer [80]={0}; time ( &rawtime ); timeinfo = localtime ( &rawtime ); btime=!btime; if(btime){ strftime (buffer,80,"Time : %I:%M%:%S p.\n",timeinfo); return std::string(buffer); } return std::string(asctime (timeinfo)); }

No comments:

Post a Comment

would you like it. :)