VC学习-系统时间和日期获取
VC学习 - 获取当前日期与时间
2010-06-18 03:09
#include “windows.h”
#include “stdio.h”
void getDateTime(
int \*year , // 年
int \*month , // 月
int \*day , // 日
int \*h , // 时
int \*m , // 分
int \*s , // 秒
int \*ss //毫秒 千分之一秒
)
{
SYSTEMTIME tm1;
GetLocalTime( &tm1);
*year = tm1.wYear;
*month = tm1.wMonth;
*day = tm1.wDay;
*h = tm1.wHour;
*m = tm1.wMinute;
*s = tm1.wSecond ;
*ss = tm1.wMilliseconds ;
}
int main( void)
{
int y,mon,d, h,m,s,ss;
getDateTime( &y,&mon,&d, &h,&m,&s,&ss);
printf( “now is %d-%d-%d %d:%d:%d %d\n”, y,mon,d, h,m,s,ss);
getchar();
return 0;
}
还没有评论,来说两句吧...