我已经通过降序完成了datetime命令,但是它显示了不正确的降序。应该是3月17日2017/7 / 2017,3 / 6/2017。但我得到低于输出
示例数据
130 3/7/2017 1:03:48 PM UP
288 3/6/2017 1:02:59 PM UP
289 3/5/2017 9:57:37 PM DN
343 3/5/2017 1:18:25 PM UP
344 3/4/2017 9:50:12 AM DN
497 3/4/2017 3:03:38 PM
887 3/3/2017 1:17:53 PM DN
888 3/3/2017 1:17:44 PM UP
889 3/17/2017 11:32:48 AM UP
890 3/17/2017 11:32:38 AM UP
码
public ActionResult pir()
{
List<PIRDetailsViewModel> model = new List<PIRDetailsViewModel>();
model.AddRange(getPirDetails("0000acfffe588041"));
model = model.OrderByDescending(x => x.UpdatedTime).ToList();
return View(model);
}
binModel.UpdatedTime = TimeZoneInfo.ConvertTimeFromUtc(Convert.ToDateTime(bin.timestamp), TimeZoneInfo.FindSystemTimeZoneById("India Standard Time")).ToString();
数据类型
public string UpdatedTime { get; set; }
答案 0 :(得分:3)
我猜你的UpdatedTime是String类型,将它解析为DateTime或将其保存为Date,
var orderedList = model.OrderByDescending(x => DateTime.Parse(x.UpdatedTime)).ToList();