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.
Asked
Active
Viewed 1,344 times
0

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

Diego Cea López
- 25
- 5
-
What's the language? And what did you try? – Yu Hao Apr 25 '15 at 11:12
-
C++ using the Windows API. I have tried to do this using the time.h library and the time_t and timeinfo structure but I couldn't figure out how to do this. – Diego Cea López Apr 25 '15 at 11:49
-
possible duplicate of [UnixTime to readable date](http://stackoverflow.com/questions/13536886/unixtime-to-readable-date) – pacholik Apr 25 '15 at 11:57
-
possible duplicate of [How to get current time and date in C++?](http://stackoverflow.com/questions/997946/how-to-get-current-time-and-date-in-c) – Ashkan Mobayen Khiabani Apr 25 '15 at 21:43
1 Answers
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

Don't stop forking
- 187
- 8