I want to pass the date parameter from C# like this:
2010-11-30 15:54:20.047
I googled it many 开发者_运维知识库ways, but none of the options gave me a solution. Can anyone tell me how to do this?
dateTime.ToString("yyyy-MM-dd HH:mm:ss.fff");
Depending on your exact requirements, you may wish to use the ToString
overload that takes an IFormatProvider
:
dateTime.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture);
Here is a more generic listing if you decide you want some other format. http://www.csharp-examples.net/string-format-datetime/
精彩评论