发布:2023/6/16 16:05:29作者:管理员 来源:本站 浏览次数:566
1、相差秒
public double DiffSeconds(DateTime startTime,DateTime endTime){
TimeSpan secondSpan=new TimeSpan(endTime.Ticks-startTime.Ticks);
return secondSpand.TotalSeconds;
}
2、相差分钟
public double DiffMinutes(DateTime startTime,DateTime endTime){
TimeSpan minuteSpan=new TimeSpan(endTime.Ticks-startTime.Ticks);
return minuteSpan.TotalMinutes;
}
3、相差小时
public double DiffHours(DateTime startTime,DateTime endTime){
TimeSpan hoursSpan=new TimeSpan(endTime.Ticks-startTime.Ticks);
return hoursSpan.TotalHours;
}
4、相差天数
public double DiffDays(DateTime startTime,DateTime endTime){
TimeSpan daysSpan=new TimeSpan(endTime.Ticks-startTime.Ticks);
return daysSpan.TotalDays;
}
public int DiffDays(DateTime startTime,DateTime endTime){
TimeSpan daysSpan=new TimeSpan(endTime.Ticks-startTime.Ticks);
return daysSpan.Days;
}
© Copyright 2014 - 2024 柏港建站平台 ejk5.com. 渝ICP备16000791号-4