#include <iostream>
#include <time.h>
void getCalendarTime()
{
time_t lt;
lt = time(NULL);
std::cout<<"The Calendar Time is "<<lt<<std::endl;
//當下時間 - 1970年1月1日0時0秒
}
void getProcessTime()
{
clock_t start, finish;
double duration;
start = clock();
/*do process*/
finish = clock();
duration = (double)(finish - start);
std::cout<<"Process Time is "<<start<<" "<<duration<<" "<<finish<<std::endl;
}
void getHours()
{
struct tm *local;
time_t t;
t = time(NULL);
local = localtime(&t);
std::cout<<"Local hour is : "<<local->tm_hour<<std::endl;
local = gmtime(&t);
std::cout<<"UTC hour is : "<<local->tm_hour<<std::endl;
}
int main ()
{
getCalendarTime();
getProcessTime();
getHours();
return 0;
}
c++ 时间处理
最新推荐文章于 2024-05-23 22:23:30 发布