干啥非要用time函数, 用clock就到毫秒了. 它是直接返回毫秒.1.使用ctime类(获取系统当前时间,精确到秒)cstring str;//获取系统时间ctime tm;tm=ctime::getcurrenttime();//获取系统日期str=tm.format("现在时间是%y年%m月%d日 %x");messagebox(str,null,mb_ok);a,从ctimet中提取年月日时分秒 ctime t = ctime::getcurrenttime(); int d=t.getday(); //获得几号 int y=t.getyear(); //获取年份 int m=t.getmonth(); //获取当前月份 int h=t.gethour(); //获取当前为几时 int mm=t.getminute(); //获取分钟 int s=t.getsecond(); //获取秒 int w=t.getdayofweek(); //获取星期几,注意1为星期天,7为星期六b,计算两段时间的差值,可以使用ctimespan类,具体使用方法如下: ctime t1( 1999, 3, 19, 22, 15, 0 ); ctime t = ctime::getcurrenttime(); ctimespan span=t-t1; //计算当前系统时间与时间t1的间隔 int iday=span.getdays(); //获取这段时间间隔共有多少天 int ihour=span.gettotalhours(); //获取总共有多少小时 int imin=span.gettotalminutes();//获取总共有多少分钟 int isec=span.gettotalseconds();//获取总共有多少秒c,获得当前日期和时间,并可以转化为cstring ctime tm=ctime::getcurrenttime(); cstring str=tm.format("%y-%m-%d");//显示年月日2.使用getlocaltime:windows api 函数,获取当地的当前系统日期和时间 (精确到毫秒) 此函数会把获取的系统时间信息存储到systemtime结构体里边 typedef struct _systemtime word wyear;//年 word wmonth;//月 word wdayofweek;//星期:0为星期日,1为星期一,2为星期二…… word wday;//日 word whour;//时 word wminute;//分 word wsecond;//秒 word wmilliseconds;//毫秒 }systemtime,*psystemtime;