开发者

How can I pass a date parameter in an arbitrary format using C#?

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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜