Note that strptime mentioned in accepted answer is not portable. Here's handy C++11 code I use to convert string to std::time_t :
static std::time_t to_time_t(const std::string& str, bool is_dst = false, const std::string& format = "%Y-%b-%d %H:%M:%S")
{
std::tm t = {0};
t.tm_isdst = is_dst ? 1 : 0;
std::istringstream ss(str);
ss >> std::get_time(&t, format.c_str());
return mktime(&t);
}
You can call it like this:
std::time_t t = to_time_t("2018-February-12 23:12:34");
You can find string format parameters here.