我有一个日期值,例如:
string date = "02/14/2015" //(MM/DD/YYY)
我想将其转换为ISO日期格式。无论如何都要这样做..
答案 0 :(得分:0)
使用DateTime.ParseExact(dateString, format, provider);
功能。
https://msdn.microsoft.com/en-us/library/w2sa9yss%28v=vs.110%29.aspx
示例:强>
CultureInfo provider = CultureInfo.InvariantCulture;
string date = "02/14/2015";
string format = "dd/mm/yyyy";
// Result is now a DateTime and can be easily converted
DateTime result = DateTime.ParseExact(date, format, provider);
答案 1 :(得分:0)
试试这个:
string date = "02/14/2015"
DateTime NewDate= DateTime.ParseExact(dateString, "MM/DD/YYYY",
CultureInfo.InvariantCulture);
string NewFmt=NewDate.ToString("yyyy/MM/DD");
答案 2 :(得分:0)
试试这个...
string date = "02/14/2015";
DateTime d2 = DateTime.Parse(date, null, DateTimeStyles.RoundtripKind);