xbonez xbonez - 1 year ago 155
C# Question

Storing current time without milliseconds component

I have a timespan object that needs to hold only time, without date. I would use


but the problem is it gives time in the format


I don't want the milliseconds component. How can I trim it out?

Answer Source

You can either use DateTime.Now.Hour/Minute/Second properties or you could use DateTime.Now.ToString("HH:mm:ss").

Refer here for more info: http://msdn.microsoft.com/en-us/library/zdtaw1bw.aspx

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download