How to subtract time in asp.net

Solution

DateTime d1 = new DateTime();
DateTime d2 = new DateTime();
d1 = Convert.ToDateTime(“12:05:45 pm”);
d2 = DateTime.Now;
TimeSpan d3 = d2 – d1;
Response.Write(d3.Hours + ” Hours “);
Response.Write(d3.Minutes + ” Minutes “);
Response.Write(d3.Seconds + ” Seconds “);

About the Author

avatar