NX二次开发源码分享:用C的方法获取当前系统时间
NX二次开发源码分享:用C的方法获取当前系统时间函数已经OK了,记住加入头文件 #include<time.h>
代码 如下:
int getLocalTime()
{
int year;
int month;
int day;
int hour;
int mins;
int secs;
char msg;
time_t getTime;
struct tm* newTime;
time(&getTime);
newTime = localtime(&getTime);
year = newTime->tm_year +2000-100;
month = newTime->tm_mon + 1;
day = newTime->tm_mday;
hour = newTime->tm_hour;
mins =newTime->tm_min;
secs = newTime->tm_sec;
sprintf(msg,"%d/%d/%d %d:%d:%d",year,month,day,hour,mins,secs);
uc1601(msg,1);
}
页:
[1]