VC获取本地当前时间

  1.自定义函数:void MyGetDateTime ( char * buff )
                  {
                     WORD  sYear,sMonth,sDay,sHour,sMinute,sSecond;
                     SYSTEMTIME  CurTime;/////定义SYSTEMTIME类的对象
                     GetLocalTime(&CurTime);////获取本地时间
                     sYear=CurTime.wYear;////获得年
                     sM.wMonth;//获得月
                     sDay=CurTime.wDay;
                     sHour=CurTime.wHour;
                     sMinute=CurTime.wMinute;
                     sSec.wSecond;
                     sprintf(buff,"%d,%d,%d,%d,%d,%d",sYear,sMonth,sDay,sHour,sMinute,sSecond);///将年月日时分秒放进buff里  
                  }
2.调用时:
              char  b[20];
              MyGetDateTime(b);////数组名字其实就是指针

你可能感兴趣的:(VC获取本地当前时间)