Need to display the resultant time in hours:min:sec format.
-
Hi, i need to display the times on my webpage. They are start time, end time and the reultant time. i wrote the following code. TimeSpan _starttime = DateTime.Now.TimeOfDay; TimeSpan _endtime = DateTime.Now.TimeOfDay; TimeSpan _finaltime = _endtime.Subtract(_starttime); Response.write("Start Time: " + _starttime + "-- End Time: " + _endtime + "-- Finaltime:" + _finaltime); i am getting result as 02:45:27.9085452-- End Time: 02:52:59.2926579-- Finaltime:00:07:31.3841127 Here i am getting milliseconds...how to avoid this in displaying. i want to display time as 02:45:27
G. Satish
-
Hi, i need to display the times on my webpage. They are start time, end time and the reultant time. i wrote the following code. TimeSpan _starttime = DateTime.Now.TimeOfDay; TimeSpan _endtime = DateTime.Now.TimeOfDay; TimeSpan _finaltime = _endtime.Subtract(_starttime); Response.write("Start Time: " + _starttime + "-- End Time: " + _endtime + "-- Finaltime:" + _finaltime); i am getting result as 02:45:27.9085452-- End Time: 02:52:59.2926579-- Finaltime:00:07:31.3841127 Here i am getting milliseconds...how to avoid this in displaying. i want to display time as 02:45:27
G. Satish
Use ToString[^]. See the different pattern
ToString
takes. Alternatively, you can use StopWatch[^] class. :)Navaneeth How to use google | Ask smart questions
-
Hi, i need to display the times on my webpage. They are start time, end time and the reultant time. i wrote the following code. TimeSpan _starttime = DateTime.Now.TimeOfDay; TimeSpan _endtime = DateTime.Now.TimeOfDay; TimeSpan _finaltime = _endtime.Subtract(_starttime); Response.write("Start Time: " + _starttime + "-- End Time: " + _endtime + "-- Finaltime:" + _finaltime); i am getting result as 02:45:27.9085452-- End Time: 02:52:59.2926579-- Finaltime:00:07:31.3841127 Here i am getting milliseconds...how to avoid this in displaying. i want to display time as 02:45:27
G. Satish
use DateTime.Now.ToString("hh:mm:ss")
-
Hi, i need to display the times on my webpage. They are start time, end time and the reultant time. i wrote the following code. TimeSpan _starttime = DateTime.Now.TimeOfDay; TimeSpan _endtime = DateTime.Now.TimeOfDay; TimeSpan _finaltime = _endtime.Subtract(_starttime); Response.write("Start Time: " + _starttime + "-- End Time: " + _endtime + "-- Finaltime:" + _finaltime); i am getting result as 02:45:27.9085452-- End Time: 02:52:59.2926579-- Finaltime:00:07:31.3841127 Here i am getting milliseconds...how to avoid this in displaying. i want to display time as 02:45:27
G. Satish
various way to achieve this but easiest way is as sachin describe DateTime.now.ToString("hh:mm:ss")//suggested Or altername when you bind the data its change the string format(for knowledge purpose) Regards Keyur Satyadev