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

Top 5 Contributors of the Month
Sandeep Singh
Melody Anderson
Eminent IT

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;


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

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



Further Readings:


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