Get Unix timestamp with C++

后端 未结 7 593
南旧
南旧 2020-12-02 20:00

How do I get a uint unix timestamp in C++? I\'ve googled a bit and it seems that most methods are looking for more convoluted ways to represent time. Can\'t I j

7条回答
  •  -上瘾入骨i
    2020-12-02 20:19

    #include
    #include
    
    int main()
    {
        std::time_t t = std::time(0);  // t is an integer type
        std::cout << t << " seconds since 01-Jan-1970\n";
        return 0;
    }
    

提交回复
热议问题