我想根据指定的格式以日期格式显示最终结果,即 YYMMDD
我如何从如下给出的字符串中获取此结果
string s="110326";
最佳答案
从字符串到日期:
DateTime d = DateTime.ParseExact(s, "yyMMdd", CultureInfo.InvariantCulture);
或者反过来:
string s = d.ToString("yyMMdd");
另请参阅这篇文章:Custom Date and Time Format Strings
关于c# - 按照指定格式将字符串转换为日期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6747220/