如何在给定两个日期分钟时间跨度弄? [英] How do I get TimeSpan in minutes given two Dates?

查看:115
本文介绍了如何在给定两个日期分钟时间跨度弄?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要在分钟,从给定两个日期我做以下



获得时间跨度

  INT totalMinutes = 0; 
时间跨度outresult = end.Subtract(开始);
totalMinutes = totalMinutes +((end.Subtract(开始).Days)* 24 * 60)+((end.Subtract(开始).Hours)* 60)+(end.Subtract(开始).Minutes) ;
返回totalMinutes;



有没有更好的办法?


解决方案

 时间跨度跨度=年底启动; 
双totalMinutes = span.TotalMinutes;


To get TimeSpan in minutes from given two Dates I am doing the following

int totalMinutes = 0;
TimeSpan outresult = end.Subtract(start);
totalMinutes = totalMinutes + ((end.Subtract(start).Days) * 24 * 60) + ((end.Subtract(start).Hours) * 60) +(end.Subtract(start).Minutes);
return totalMinutes;

Is there a better way?

解决方案

TimeSpan span = end-start;
double totalMinutes = span.TotalMinutes;

这篇关于如何在给定两个日期分钟时间跨度弄?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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