如何在C#中减去datagridview列时间和系统当前时间 [英] How to subtract datagridview column time and system current time in C#

查看:108
本文介绍了如何在C#中减去datagridview列时间和系统当前时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,伙计们,我希望你们一切顺利。好吧,我现在在我的项目中遇到一个问题,我想知道如何在c#

中减去Datagridview列时间和系统当前时间,例如,如果我把时间放在3:20:02数据网格视图列和15分钟后我检查数据网格视图所以当前时间将是3:35.02我想减去这个时间并想在另一个数据网格视图列中获取值,如00:15:00。

谢谢



我尝试过:



datagridview1。 row.cell [1] = datagridview1.Row.cell [0] .value - system.datetime.now.tostring();

解决方案

我会设置一个变量为类型System.DateTime然后分配datagridview单元格值,然后执行类似变量= System.DateTime.Now - 变量

然后我将它分配给新的单元格位置与类似datagridview1.row.cell [1] = variable.ToString();


你可以转换为时间戳



2017年6月14日= 1497401466



2017年6月13日= 1497315066



var resu = 1497401466 - 1497315066;


Hello, Guys, I hope you all will be fine. Well I am a facing an issue nowadays in my project that is I want to know How to subtract Datagridview Column Time and system current time in c#
for example, if I put time 3:20:02 in data grid view columns and after 15 minutes when I check data grid view so current time will be 3:35.02 I want to minus this time and wanna get value in another data grid view column like 00:15:00.
Thanks

What I have tried:

datagridview1.row.cell[1] = datagridview1.Row.cell[0].value - system.datetime.now.tostring();

解决方案

I would setup a variable to be of type System.DateTime then assign the datagridview cell value to it, then do something like variable = System.DateTime.Now - variable
then I would assign it to the new cell location with something like datagridview1.row.cell[1] = variable.ToString();


you can convert to timestamp

June 14, 2017 = 1497401466

June 13, 2017 = 1497315066

var resu = 1497401466 - 1497315066;


这篇关于如何在C#中减去datagridview列时间和系统当前时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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