显示当前系统时间(Linux C++)
显示当前系统时间(Linux C++)
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
int x,h,m,s;
x=time(NULL);
h=x/3600%24+8; //中国时区加8
m=x%3600/60;
s=x%3600%60;
cout<<"The current time is:"<<h<<":"<<m<<":"<<s<<endl;
return 0;
}
评论暂时关闭