0

I need to convert st_mtime returned from the stat structure as given here man page for stat function into c++ string.

struct stat fs;
stat(some_path, &fs);
auto modificationTime = fs.st_mtime;

// Convert modificationTime into C++ string

How could I do this?

One of the solution I saw was std::to_string(static_cast<long>(fs.st_mtime))). Could someone also explain what is happening here?

chux - Reinstate Monica
  • 143,097
  • 13
  • 135
  • 256
Amanda
  • 2,013
  • 3
  • 24
  • 57
  • 1
    https://stackoverflow.com/questions/997512/string-representation-of-time-t – adrien bedel Apr 12 '20 at 08:59
  • Why did you tag `c`? are you interested in C based answers (ones that might get you a C string rather than a C++ String instance)? – Myst Apr 12 '20 at 08:59
  • Does this answer your question? [String representation of time\_t?](https://stackoverflow.com/questions/997512/string-representation-of-time-t) – Myst Apr 12 '20 at 09:02

0 Answers0