版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u011508145/article/details/79992242
直接切入问题:UI及前端传递的时间参数为:2000-06-26T16:00:00Z
在Controller中如果请求的参数类型为时间类型的话,DateTime.Kind会是UTC,中国地区的会减少8个小时,所以需要调整一下WebApiConfig,将其设置为Local本地时间
WebApiConfig添加:
var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
json.Indent = false;
json.SerializerSettings.DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Local;