net 4 和 c#。
我在文本框中有 DateTimeValue
3/1/2011 12:00:00 AM
我需要将它转换成这种格式的字符串:
Format="yyyy-MM-dd"
知道怎么做吗? PS:我可以删除有关时间的信息
谢谢你的时间
最佳答案
使用DateTime.ParseExact像这样:
DateTime.ParseExact("3/1/2011 12:00:00 AM", "G",
CultureInfo.GetCultureInfo("en-US")).ToString("yyyy-MM-dd");
请务必指定文化,因为您使用的格式不明确。
关于c# - 转换日期时间格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5152191/