您的位置:首页 > 运维架构 > Linux

修改系统时间 (windows,Linux)

2012-02-27 17:55 519 查看
windows下的修改系统时间

void UIManager::setSysTime()
{
//#include <windows.h>
//#include <stdlib.h>
SYSTEMTIME s;
//GetLocalTime(&s); //SetLocalTime(&s)
//GetSystemTime()获取的格林尼治时间, 是全球标准时间。SetSystemTime(&s)
s.wYear=2000+temp[0]*10+temp[1];
s.wMonth=temp[2]*10+temp[3];
s.wDay=temp[4]*10+temp[5];
s.wHour=temp[6]*10+temp[7];
s.wMinute=temp[8]*10+temp[9];
if(SetLocalTime(&s))
cout<<"setting time is success"<<endl;
else
cout<<"setting time is not success"<<endl;
}

 

linux下的修改系统时间 

void UIManager::SetHwColock(string dateTime)
{
string d="sudo date -s '"+dateTime+"'";//要输入密码,在板子上去掉sudo
system(d.c_str());
system("sudo hwclock --systohc");//要输入密码,在板子上去掉sudo
//system("sudo hwclock");//验证是否修改成功
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: