labwindows吧 关注:171贴子:237
  • 1回复贴,共1

关于CVI实时获取系统的时间并显示

只看楼主收藏回复

请问labwindows中怎么获取系统的时间并且实时显示?我找到了GetCurrentDateTime这个函数,但是得到的是double型的数据,不知道怎么转成正确的时间?请大神指点一二,谢谢~


1楼2018-01-03 23:37回复
    GetCurrentDateTime (&d_currenttime);//获取1900.1.1至今的秒数
    GetDateTimeElements (d_currenttime,&i_hour,&i_minute,&d_second,&i_month,&i_day,&i_year); //将其转化为年月日时分秒的形式
    sprintf(c_hour,"%d",i_hour);//将int类型数据转化为字符串
    sprintf(c_minute,"%d",i_minute);
    sprintf(c_second,"%.0f",d_second);
    strcpy(c_currenttime,strcat(strcat(strcat(strcat(c_hour,c_colon),c_minute),c_colon),c_second));//连接字符串


    2楼2018-09-24 09:22
    回复