两个日期之间的日,小时,分钟,秒 [英] Days, hours, minutes, seconds between two dates
本文介绍了两个日期之间的日,小时,分钟,秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
0天,0小时,23分18秒
表示两个日期之间的差异。如何获取这个字符串的这些元素?
解决方案
TimeSpan 是您需要的对象:
TimeSpan span =(DateTime.Now - DateTime.Now);
String.Format({0} days,{1} hours,{2} minutes,{3} seconds,
span.Days,span.Hours,span.Minutes,跨度);
I have two dates, one less than the other. I want to create a string such as this one
"0 days, 0 hours, 23 minutes, 18 seconds"
representing the difference between the two dates. How can I get these elements of this string?
解决方案
TimeSpan is the object you need:
TimeSpan span = (DateTime.Now - DateTime.Now);
String.Format("{0} days, {1} hours, {2} minutes, {3} seconds",
span.Days, span.Hours, span.Minutes, span.Seconds);
这篇关于两个日期之间的日,小时,分钟,秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文