Std::Chrono - Wrong Epoch Time

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,
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;
    
}

Screen Shot 2022-10-30 at 1.06.02 PM.webp

Any help would be much appreciated , Thank you !
 
Back
Top Bottom