Jacque Scott
asked on
Get difference between two times
I have a start time and an end time. I need the difference between the two.
I am new to C# and need the best way to do this. I am sure this is wrong but this is basically what I need to do.
I am new to C# and need the best way to do this. I am sure this is wrong but this is basically what I need to do.
DateTime StartTime = DateTime.Now;
DateTime EndTime = DateTime.Now;
label1.Text = "Total time to do project: " + DateDiff(StartTime, EndTime);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
*No Points*
Shaun is correct. Proof of concept:
Shaun is correct. Proof of concept:
using System;
namespace EE_Q28713211
{
class Program
{
static void Main(string[] args)
{
DateTime start = new DateTime(2015, 11, 9, 4, 30, 00);
DateTime end = new DateTime(2015, 11, 9, 5, 15, 00);
Console.WriteLine("Difference between {0} and {1} is {2} minutes.", start.ToString("h:mm"), end.ToString("h:mm"), (end - start).TotalMinutes);
Console.ReadLine();
}
}
}
Produces the following output --saige-
ASKER