如何在asp.net中显示日期时间c# [英] how to show date time duration in asp net c#

查看:195
本文介绍了如何在asp.net中显示日期时间c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站上有一名员工,我的数据库中有开始日期和结束日期。现在,如何显示持续时间,例如



员工< br $>
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#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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