开发者

.NET DateTime to String

Is there a easy way to convert a DateTime object to a string representation like this '2010-03-03 10:38:48'.

I'm not sure what the above format is but it is different from the patterns obtainable via T开发者_JAVA技巧oLongTimeString() etc.

Is this a case for string builder?


Like this:

date.ToString("yyyy-MM-dd hh:mm:ss")

If you want 24 hour time, replace hh with HH.

For more information, see here.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜