如何减去两个日期值,以便在几分钟内获得时间asp.net c# [英] How to Subtract to two Date values to get time in minutes asp.net c#
本文介绍了如何减去两个日期值,以便在几分钟内获得时间asp.net c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
DateTime dt =04/20/2015 6:30:00;
DateTime dt =04/10/2015 6:30:00;
如何获得两个值的分钟差异
Plz帮助朋友.......
DateTime dt = "04/20/2015 6:30:00";
DateTime dt = "04/10/2015 6:30:00";
How to get difference in minute for the two values
Plz help friends.......
推荐答案
试试这个:
Try this:
DateTime dt1 = new DateTime(2015,10,4, 6,30,0);
DateTime dt2 = new DateTime (2015,10,4, 6,22,0);
TimeSpan ts = dt2-dt1;
Console.WriteLine("Difference in minutes: {0}", ts.TotalMinutes);
//Result: 8
感谢Richard的宝贵建议。
Thank you Richard for your valuable suggestion.
这篇关于如何减去两个日期值,以便在几分钟内获得时间asp.net c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文