2012-03-21 113 views

回答

2

是的,有可能,請參閱下面的strTime,它的值是「0:0:0」。但是,如果您正在尋找時間間隔,而不是實際時間,請更好地使用CTimeSpan,另請參閱下文。

time_t date1_t, date2_t; 
    tm date_tm; 

    date_tm.tm_hour =0; 
    date_tm.tm_min =0; 
    date_tm.tm_mon =0; 
    date_tm.tm_sec =0; 
    date_tm.tm_wday =0; //Day of week (0-6; Sunday = 0) 
    date_tm.tm_yday =1; 
    date_tm.tm_year =97; 
    date_tm.tm_isdst =-1; //Positive if Daylight Saving Time is in effect; 
         //0 if Daylight Saving Time is not in effect; 
         //Negative if status of DST is unknown. 

    date_tm.tm_mday =0; 
    date2_t = mktime(&date_tm); 

    date_tm.tm_mday =0; 
    date_tm.tm_isdst =0; 
    date1_t = mktime(&date_tm); 

    CTime time1(date1_t), time2(date2_t); 
    CTimeSpan ts = time2 - time1; 
    CString strTime = time1.Format("%H:%M:%S"); 
+0

謝謝,請看CTimeSpan。 – besworland 2012-03-21 15:36:42