-1

我以这种格式从 javascript 中获取 C# 中的日期:

"Tue Jan 15 00:00:00 UTC+0530 2008".

如何将其转换为"dd/MMM/yyyy"格式?

4

2 回答 2

1
 var jsdate = "Tue Jan 15 00:00:00 UTC+0530 2008";
 var format = "ddd MMM d HH:mm:ss UTCzzzzz yyyy";
 var date = DateTime.ParseExact(jsdate, format, CultureInfo.InvariantCulture);

 Console.WriteLine(date.ToString("dd/MMM/yyyy"));
于 2012-11-03T10:05:45.320 回答
1

试试这个:

var test = "Tue Jan 15 00:00:00 UTC+0530 2008";
const string format = "ddd MMM d HH:mm:ss zzz yyyy";

var var = DateTime.ParseExact(test.Replace("UTC", ""), format, CultureInfo.InvariantCulture);
Console.WriteLine(var);
于 2012-11-03T10:07:28.177 回答