.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> DateTime >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

How to find the Duration Time between two Times using C#

Posted By:Syed Shakeer Hussain       Posted Date: August 07, 2010    Points: 10    Category: DateTime    URL: http://www.dotnetspark.com  

The Below code is usefull to find the duration between two Times.
 


DateTime StartTime = DateTime.Now.ToLocalTime();

DateTime EndTime = DateTime.Now.ToLocalTime();

string dt = EndTime.Subtract(StartTime).ToString().Split('.')[0].ToString();

button1.Text = dt;


OutPut:

StartTime:8/7/2010 3:31:16 PM

EndTime:8/7/2010 3:32:07 PM

dt=00:00:50




     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend