字符串之间的持续时间为两次 [英] Duration between two times as Strings

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

问题描述

全部好,



我计算字符串之间的持续时间有问题,



次比如ex:



var time1 =''10:32'';



var time2 =' '12:57'';



我想计算时间2 - 时间1?总小时和分钟



请尽快帮帮我?





谢谢

Ganesh

HI All,

I have problem with calculating duration between times as strings,

times like ex:

var time1 = ''10:32'';

var time2 = ''12:57'';

and i want to calculate time2 - time1?with total hours and mins

please help me asap?


Thanks
Ganesh

推荐答案

获取该字符串并将其转换为TimeSpan字段,然后取出差异。



了解 TimeSpan 。您需要找到时间和时间之间的差异。使用Timespan,您可以获得小时/分钟/秒等的差异。



参考:

MSDN:TimeSpan结构 [ ^ ]

MSDN:TimeSpan.Parse方法(字符串) [ ^ ]
Take that string and convert it into TimeSpan field and then take the difference.

Read about TimeSpan. You need to find the difference between the to time and the from time. Using Timespan, you get the difference in terms of hours/minutes/seconds, etc.

Refer:
MSDN: TimeSpan Structure[^]
MSDN: TimeSpan.Parse Method (String)[^]


这篇关于字符串之间的持续时间为两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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