Supports cross-origin code, time is converted to a fixed format, local time
In the Application_BeginRequest method of Global:
Thread. CurrentThread. CurrentCulture = new CultureInfo ("zh-CN ");
Thread. CurrentThread. CurrentUICulture = new CultureInfo ("zh-CN ");
Add the following code in the Initialize () method of WebApiModule:
// Cross-origin code GlobalConfiguration. configuration. enableCors (new enablecorsattricors ("*", "*", "*"); // Json time format Clock. provider = ClockProviders. local; GlobalConfiguration. configuration. formatters. jsonFormatter. serializerSettings. dateFormatString = "yyyy-MM-dd HH: mm: ss"; GlobalConfiguration. configuration. formatters. jsonFormatter. serializerSettings. converters. where (x => x is Abp. json. abpDateTimeConverter ). asEnumerable (). toList (). forEach (x => {(x as Abp. json. abpDateTimeConverter ). dateTimeFormat = "yyyy-MM-dd HH: mm: ss ";});
If it does not work:
In the object class, you can force the conversion when the attribute is assigned a value:
String creationTime; // <summary> // creation time // </summary> public string CreationTime {get {if (this. id = 0) {return "";} return creationTime;} set {creationTime = String. isNullOrEmpty (value )? "": (DateTime. Parse (value). ToString ("yyyy-MM-dd HH: mm: ss ");}}