c语言设置qnx系统时间

来源:互联网 发布:ios刷机会丢失数据吗 编辑:程序博客网 时间:2024/06/14 01:33
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>


int main( void )
  {
    struct timespec stime;
    struct tm *ptm;
    time_t tvtmp, tvsec;
    ptm=localtime(&tvtmp);
    ptm->tm_hour = 14;
    ptm->tm_min = 30;
    ptm->tm_year = 2015-1900;
    tvsec = mktime(ptm);




    stime.tv_sec = tvsec;  /* Add one day */
    stime.tv_nsec = 0;
    if( clock_settime( CLOCK_REALTIME, &stime) == -1 ) {
       perror( "setclock" );
       return EXIT_FAILURE;
    }
    printf("Currenttime=%s",asctime(ptm));


    return EXIT_SUCCESS;

  }


注:时区需要注意TZ=CCT-8

0 0