Sunday, December 27, 2009

By default, in c# DateTime object will display the values in the 12 hours format with AM and PM. Which don't include the milliseconds. But how to display the date and time with milliseconds? Use the below format to display it.

DateTimeObject.ToString("yyyy-MM-dd HH:mm:ss.fff")

f is for the format for printing the milliseconds. Remember when you try to convert the date time with milliseconds back to C# Date time, then just use Convert.ToDateTime().

Hope this helps.

Categories: , ,


Post a Comment