Get time ticks in DateTime format C#

Date time comes from Database side like this "2021-03-08T21:27:21.065" and then i have tried and format it from C# side like below,

string fullDate = Convert.ToDateTime(x.start_date).ToString("dd-MM-yyyy HH:mm:ss");

But i need to show last part of the date 065 as well.

1 answer

  • answered 2021-03-08 17:36 Kazi Mohammad Ali Nur

    "dd-MM-yyyy HH:mm:ss.fff" is the format to include milliseconds. Please try this:

    string fullDate = Convert.ToDateTime(x.start_date).ToString("dd-MM-yyyy HH:mm:ss.fff");