0

I am writing a tool for a game and I am reading it's memory to retrieve the system time of the messages sent to the game's chat. That time is in the format of an integer containing the current system time as 1429959524, for example. How could I convert this value to a formatted time string as HOURS:MINUTES:SECONDS? I can't figure out a simple way to do this.

Yu Hao
  • 119,891
  • 44
  • 235
  • 294

1 Answers1

0

With the <ctime> header you can get the time formatted nicely in a string by using strftime

time_t rawtime;
struct tm * timeinfo;
char buffer[10];
time (&rawtime);
timeinfo = localtime(&rawtime);
strftime(buffer,10,"%I:%M:%S",timeinfo);
std::string str(buffer);

Orifinally explained at Current date and time as string

Community
  • 1
  • 1