- Joined
- 1/21/19
- Messages
- 313
- Points
- 138
I want to tranform a string to system time point and then calculate time since epoch but for some reason my program returns 5 hours for the below Unix time stamp,
Any help would be much appreciated , Thank you !
C++:
void func()
{
std::tm tm = {};
std::stringstream ss("1970-01-01 00:00:00");
ss >> std::get_time(&tm, "%Y-%m-%d %H:%M:%S");
std::cout << std::put_time(&tm, "%c") << '\n';
const auto output = std::chrono::time_point_cast<chrono::hours>(chrono::system_clock::from_time_t(mktime(&tm)));
std::cout << output.time_since_epoch().count() << std::endl;
}
Any help would be much appreciated , Thank you !