源码:
#include <iostream>
#include <chrono>
#include <ctime>
#include <thread>using namespace std;
int main() {cout << "===使用C99方式获取系统时间===" << endl;time_t now = time(nullptr);struct tm *tm_c99 = localtime(&now);cout <<"使用localtime与asctime函数获取系统时间: ==> " <<asctime(tm_c99) << endl;struct tm *tm_c99_fmt = localtime(&now);char buf[80]={0};strftime(buf,sizeof(buf),"%Y-%m-%d %H:%M:%S",tm_c99_fmt);cout<<"格式化输出系统时间: "<<buf<<endl;