Skip to content

Instantly share code, notes, and snippets.

@psycharo-zz
Created April 23, 2014 08:00
Show Gist options
  • Save psycharo-zz/11206272 to your computer and use it in GitHub Desktop.
Save psycharo-zz/11206272 to your computer and use it in GitHub Desktop.
get a (date) timestamp in c++
#include <ctime>
using namespace std;
inline std::string date_string()
{
time_t rawtime;
std::time(&rawtime);
struct tm *tinfo = std::localtime(&rawtime);
char buffer[12];
strftime(buffer, 12, "%F", tinfo);
return std::string(buffer);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment