日,时,分,两个日期之间秒 [英] Days, hours, minutes, seconds between two dates
本文介绍了日,时,分,两个日期之间秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个日期,一个比另一个更小。我想创建一个字符串,如这一个
I have two dates, one less than the other. I want to create a string such as this one
0天0小时23分18秒。
"0 days, 0 hours, 23 minutes, 18 seconds"
重新presenting两个日期之间的差。我怎样才能得到这个字符串的这些元素?
representing the difference between the two dates. How can I get these elements of this string?
推荐答案
时间跨度是你需要的对象:
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屋!
查看全文