How to get current time and date in C++?

后端 未结 24 1486
刺人心
刺人心 2020-11-22 06:55

Is there a cross-platform way to get the current date and time in C++?

24条回答
  •  旧巷少年郎
    2020-11-22 07:40

    There's always the __TIMESTAMP__ preprocessor macro.

    #include 
    
    using namespace std
    
    void printBuildDateTime () {
        cout << __TIMESTAMP__ << endl;
    }
    
    int main() {
        printBuildDateTime();
    }
    

    example: Sun Apr 13 11:28:08 2014

提交回复
热议问题