如何在C#Winforms中获得登录时间和注销时间之间的差异? [英] how to get difference between login and logout time in c# winforms?

查看:170
本文介绍了如何在C#Winforms中获得登录时间和注销时间之间的差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
请帮帮我,
如何获得用户登录和注销时间的差异并将其显示在其他文本框中?

事情是登录时间应该在我们单击按钮登录时自动加载到文本框中,然后在那一刻我们单击按钮注销时自动加载.我希望当前时间加载到注销文本框中,并且希望差异显示在其他文本框中.... .

hi All ,
Please help me out,
how to get difference of user login and logout time and show it in some other textbox?

the thing is login time should automatically load in the textbox when we click on button login and later when we click on button logout at that moment I want current time to be loaded in logout textbox and difference to be displayed in other textbox.....

推荐答案

创建一个全局datetime变量,并在用户成功登录时以及用户注销得到当前datetime与您设置的变量之间的差时进行设置一开始

make a global datetime variable and set it when the user is login successfully and when the user logout get the difference between the current datetime and the variable you set it in the beginning

DateTime loginDate = new DateTime();
double  sessionHours = (DateTime.Now - loginDate).TotalHours;


您可以检查其他可以检索的数据,例如天,分钟,秒等.

希望我能帮上忙


You can check the other data you can retrieve like days , minutes , seconds and etc

Hope i could help


这篇关于如何在C#Winforms中获得登录时间和注销时间之间的差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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