0

I was looking at a similar post, that showed how to use the ctime header file, to return the time as a string, but since the release of C++11 there has been an addition that was std::chrono. But having this feature in chrono, how can I use it? Even our application uses the old ctime, header to return the date/time. This is the code, we're currently using:

#include <iostream>
#include <ctime>
#include <string>
using namespace std;
int returnTime()
{
    time_t rt;
    struct tm * timeinfo;
    char tbf[80];
    time(&rt);
    timeinfo = localtime(&rt);
    strftime(tbf, sizeof(tbf), "%d-%m-%Y %I:%M:%S", timeinfo);
string _now(tbf);
return 0;
}
Sayan N.
  • 15
  • 5

0 Answers0