当前位置:网站首页>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);
边栏推荐
- Flume (四) --------- Flume 企业开发案例
- JDBC technology (2) - set up common sql and configuration files
- 使用JS实现数组扁平化的几种方式
- etcd实现大规模服务治理应用实战
- 2.1-----27. Remove elements
- 力扣刷题记录5.1-----59. 螺旋矩阵 II
- 数字孪生+燃气管理,开启智慧燃气管理新模式
- 在树莓派上使用cpolar(番外篇2)
- How to install ngrok in Synology system (Synology 6.X version)
- D. Tournament Countdown
猜你喜欢
Electromagnetic radiation safety standards and detection methods
力扣刷题记录7.1-----707. 设计链表
力扣刷题记录4.1-----209. 长度最小的子数组
2022年自然语言处理校招社招实习必备知识点盘点分享
终于有人把灰度发布架构设计讲明白了
边缘计算的三个关键好处
JDBC technology (1) - a simple JDBC test
PMP有什么答题技巧?
MT4/MQL4 entry to proficient foreign exchange EA tutorial Lesson 1 Getting to know MetaEditor
MT4/MQ4L入门到精通EA教程第二课-MQL语言常用函数(二)-账户信息常用功能函数
随机推荐
Go-8-Gin framework
软件开发之我的一点想法
composer的使用记录
Summary of Database Design
Several ways to use JS to achieve array flattening
PMP有什么答题技巧?
D. Tournament Countdown
力扣刷题记录3.1-----977. 有序数组的平方
JDBC技术(三)——使用Druid数据库连接池测试
yii2的安装之路
程序员的日常生活 | 每日趣闻
【HNUMSC】C language second lecture
方法参数
Using ngrok on Raspberry Pi (Extra 2)
Go-8-Gin框架
年金险的安全性怎么样啊?可靠吗?
Latex示例参考
10.1-----19. Delete the Nth node from the bottom of the linked list
Mysql 5.7 into the pit
33. 分别谈谈联合索引生效和失效的条件