时间计算的麻烦 [英] Trouble With a Time Calculation

查看:55
本文介绍了时间计算的麻烦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





在我的项目中我有两次。开始时间:2013-10-04 09:00:00结束时间:2013-10-04 18:00:00



我想知道多少15分钟这些时间之间有没有。是否有任何身体都有代码可以帮助我



谢谢

parithi

Hi,

In my Project i have two Time . Start Time :2013-10-04 09:00:00 End Time: 2013-10-04 18:00:00

I want to Know how many 15 Mins are there between these time. does any body have an code to do these help me

Thanks
parithi

推荐答案



检查一下。


Check this.
DateTime dt1 = Convert.ToDateTime("2013-10-04 09:00:00");
DateTime dt2 = Convert.ToDateTime("2013-10-04 18:00:00");
TimeSpan dt;
if (dt1 > dt2)
{
    dt = dt1 - dt2;
}
else
{
    dt = dt2 - dt1;
}

double minutes = dt.TotalMinutes;
double total15min = minutes / 15;



希望它可以帮到你。

谢谢


Hope it helps you.
Thanks


这篇文章有(差不多)一切。

.NET时间段库 [ ^ ]
This article has (almost)everything.
Time Period Library for .NET[^]


这篇关于时间计算的麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆