星期一, 11月 16, 2009

c# 日期運算 timespan

string lateTime = this.itemsAgent.GetLateTestLog(this.UserID);
DateTime lateDT = DateTime.Parse(lateTime);
//string currentTime = DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss");
//日期相減
TimeSpan ts = DateTime.Now.Subtract(lateDT);
int subMin = ts.Minutes;
//日期比較
//DateTime.Compare(t1,t2),回傳一個整數小於0,则t1小於t2,大於0,则t1大於t2, =0,则t1=t2
int compareVal = DateTime.Compare(t1, t2) ;

沒有留言:

張貼留言

留個話吧:)