time格式为00:00:00的持续时间 [英] time Duration with this format 00:00:00

查看:381
本文介绍了time格式为00:00:00的持续时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
我有2个日期时间变量:enterTime& outerTime



并使用以下代码显示时间持续时间:

 timespan dif = outerTime  -  enterTime; 
textBox1.Text = dif.Duration()。toString();





显示dif.Duration的格式: 00:00:00.0000

但我希望以这种格式显示:00:00:00

解决方案

 textBox1.Text = dif.Duration()。toString( @  \ hh \:mm \:ss ); 


hi i have 2 datetime variable : enterTime & outerTime

and show Time Duration with this code :

timespan dif = outerTime - enterTime ;
textBox1.Text = dif.Duration().toString();



The format of dif.Duration is shown : 00:00:00.0000
but i want shown by this format : 00:00:00

解决方案

textBox1.Text = dif.Duration().toString(@"\hh\:mm\:ss");


这篇关于time格式为00:00:00的持续时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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