我new Date(2012,9,3)
从FormCollection["eventDate"]
如何在DateTime
变量中获取此值?
问问题
1942 次
2 回答
1
string input = "new Date(2012,9,3)";
var dateTimeString = input.Split(new[] {'(', ')'},
StringSplitOptions.RemoveEmptyEntries)
.Last();
var datetime = DateTime.ParseExact(dateTimeString,
"yyyy,M,d", CultureInfo.InvariantCulture);
于 2013-06-20T14:49:43.797 回答
0
一种方法是这样的:
// new Date(2012,9,3)
var dateVals = s.Substring(9).Replace(")", "").Split(",");
var d = new DateTime(
Convert.ToInt32(dateVals[0]),
Convert.ToInt32(dateVals[2]),
Convert.ToInt32(dateVals[1]));
于 2013-06-20T14:49:40.637 回答