Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# parse timestampwith format "yyyyMMdd HH:mm:SS.ms"

I wanted to format a string to dateTime with the format

"yyyyMMdd HH:mm:SS.ms"

I tried doing "yyyyMMdd HH:mm:SS" as the string format for ParseExact but it doesn't recognise it. Also no clue how to include the milliseconds as well

any assistance?

like image 912
Abstract Avatar asked Mar 28 '12 06:03

Abstract


1 Answers

From the custom date and time format strings page, you use ss for seconds, and FFF for milliseconds:

"yyyyMMdd HH:mm:ss.FFF"

or

"yyyyMMdd HH:mm:ss.fff"

(Use the first if trailing 0s are suppressed, the second otherwise.)

like image 153
Jon Skeet Avatar answered Sep 21 '22 13:09

Jon Skeet