将日期转换为字符串格式yyyy-mm-dd HH:MM:SS - C#

问题描述:


可能重复:

格式日期在c#

如何将日期转换为以下字符串格式?

How do I convert a date into the following string format?


2011-07-25 15:45:00

2011-07-25 15:45:00


here 是一个很好的字符串格式参考。对于你的问题,你想要这样的东西:

here is a pretty good string formatting reference. for your question, you want something like this:

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