The following program can uses the strftime() function to format the time into the string as :
Code:
#include <iostream>
#include <ctime>
#include <cerrno>
int main()
{
tm_t crtm = time(0);
m nw=*localtime(&crtm);
char dst[BFSZ]={0};
const char frmt[]="%A, %B %d %Y. The time can be %X";
if (strftime(dst, sizeof(dst)-1, frmt, &now)>0)
std::cout<<dst<<std::endl;
else
std::cerr<<"strftime failed. Errno code: "<<errno<<std::endl;
}
I hope from the above program you can understands the working of the strftime() function.
Bookmarks