开发者

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

开发者 https://www.devze.com 2023-02-02 02:38 出处:网络
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

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

精彩评论

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