当前位置:网站首页>C#计算两个时间相差多少天、时、分、秒
C#计算两个时间相差多少天、时、分、秒
2022-08-09 02:21:00 【yutiedun】
计算两个时间相差多少天、时、分、秒
DateTime DateTime1 = Convert.ToDateTime("2020-03-25 10:30:00"); //开始时间
DateTime DateTime2 = DateTime.Now; //当前时间
TimeSpan ts1 = new TimeSpan(DateTime1.Ticks);
TimeSpan ts2 = new TimeSpan(DateTime2.Ticks);
TimeSpan ts = ts1.Subtract(ts2).Duration();
string dateDiff = ts.Days.ToString() + "天" + ts.Hours.ToString() + "小时" + ts.Minutes.ToString() + "分钟" + ts.Seconds.ToString() + "秒";
MessageBox.Show("已运行" + dateDiff);
边栏推荐
- Likou Brush Question Record--Common Functions
- 数仓第二篇: 数据模型(维度建模)
- 33. 分别谈谈联合索引生效和失效的条件
- ROS2 ERROR: OpenGL 1.5 is not supported in GLRenderSystem::initialiseContext at C:\ci\ws\build...
- Summary of pytorch related knowledge points
- 边缘计算的三个关键好处
- 企业面临的五大数据安全挑战
- 【AspNetCore】实现JWT(使用Microsoft.AspNetCore.Authentication.JwtBearer)
- 力扣刷题记录4.1-----209. 长度最小的子数组
- Analysis of when AuthenticationSuccessHandler is called after UsernameAuthenticationFilter is authorized successfully
猜你喜欢
在树莓派上使用cpolar(番外篇2)
2022杭电多校第五场1007(生成函数+启发式合并+ntt)
2022 PMP Project Management Certification Exam Registration Guide (1)
Codeforces Round #809 (Div. 2)A~D1
点击div内部默认文本被选中
JDBC technology (2) - set up common sql and configuration files
MT4 / MQ4L entry to the master of EA tutorial lesson two (2) - - MQL language commonly used function account information commonly used functions
NPDP改版前最后一次考试!请注意
How SEMRush finds keywords for advertising
帮助安全红队取得成功的11条建议
随机推荐
Open3D 均匀采样
Go - 9 - data type - function
Use of torchversion.transforms
The 7 taboos of time management summarized by the postgraduate students, how many have you won?
Mysql 5.7 into the pit
Go-11-流程控制
Open3D 计算点云的均值(质心)与协方差
Using ngrok on Raspberry Pi (Extra 2)
Which is the best increased whole life insurance?Is it really safe?
KQL和Lucene的区别
为什么应用程序依赖关系映射对于云迁移至关重要
考研人总结的时间管理7大忌,你中了几条?
Force buckled brush problem record 7.1 -- -- -- -- -- 707. The design list
Likou Brush Question Record 8.1-----206. Reverse linked list
线段树知识整理
pytorch相关知识点总结
【HNUMSC】C language second lecture
MT4/MQL4入门到精通外汇EA教程第一课 认识MetaEditor
Go-9-数据类型-函数
The first lesson of HNUMSC-C language