我的网站上有一名员工,我的数据库中有开始日期和结束日期。现在,如何显示持续时间,例如 员工 Madhu Gadhe(2014 - 2018年总共4年) 开课日期:2014年12月6日9:00 他工作6个月18天12小时30分30秒 剩余3年6个月18天12小时30分30秒 i想要显示这样
解决方案你可以简单地减去两个日期时间并获得如下的TimeSpan TimeSpan工作=今天 - startdate ; TimeSpan剩余= enddate -today;
然后使用TimeSpan properties [ ^ ]您可以显示您想要的内容 请注意,您可以使用当前日期时间 DateTime.Now Property [ ^
I have an employee in my website,and i have start date and end date in my database.Now, how to show time duration for example EMPLOYEE Madhu Gadhe(total period 4 Years 2014-2018) Start Date: 12/6/2014 9:00 AM he worked 6 months 18 days 12 hours 30 minutes 30 seconds remaining 3 years 6 months 18 days 12 hours 30 minutes 30 seconds i want to show like this
解决方案 you can simply subtract two datetimes and get TimeSpan as below TimeSpan worked = today- startdate; TimeSpan remaining = enddate -today;then using TimeSpan properties[^] you can diplay what you want note that, you can get current date time using DateTime.Now Property[^]
更多推荐
如何在asp.net中显示日期时间c#
发布评论