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

后端 未结 24 2112
刺人心
刺人心 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:45

    std C libraries provide time(). This is seconds from the epoch and can be converted to date and H:M:S using standard C functions. Boost also has a time/date library that you can check.

    time_t  timev;
    time(&timev);
    

提交回复
热议问题