Sandokan Sandokan - 4 years ago 192 Question

How to get Date.Now with milliseconds?

I need to generate the current Date in that's have also the millisecond. Actually I use:


but this return a simple date as 28/12/2015 16:53, I want also the millisecond something like:

28/12/2015 16:53:48640864

I tried with:

Public Shared Function MillisecondsDate()

Return Date.Now.ToString("HH:mm:ss.fffffff")

End Function

but this return a bad result:


I need a format compatible with
for an accurate
field. Any ideas?

Answer Source

Try this function:

Public Shared Function MillisecondsDate()
    Return DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff")
End Function
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download