Reputation: 743
I am trying to convert "Tue Feb 13 00:26:36 2018" to time_t
, how can I do this, I tried looking for a function and couldn't find it. This is using unmanaged C++.
Upvotes: 2
Views: 5211
Reputation: 2278
If you are using C++11, you can do it like this.
#include <iostream>
#include <iomanip>
#include <ctime>
#include <sstream>
int main()
{
struct tm tm;
std::istringstream iss("Tue Feb 13 00:26:36 2018");
iss >> std::get_time(&tm, "%a %b %d %H:%M:%S %Y");
time_t time = mktime(&tm);
std::cout << time << std::endl;
return 0;
}
Upvotes: 3