如何在asp.net中显示日期时间c#

编程入门 行业动态 更新时间:2024-10-10 03:23:35
本文介绍了如何在asp中显示日期时间c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的网站上有一名员工,我的数据库中有开始日期和结束日期。现在,如何显示持续时间,例如 员工 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 -t​​oday;

然后使用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#

本文发布于:2023-11-27 16:13:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638706.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日期   时间   如何在   net   asp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!