在Global的 Application_BeginRequest方法中: Thread.CurrentThread.CurrentCulture = new CultureInfo("zh-CN"); Thread.CurrentThread.CurrentUICulture = new Cult ...
在Global的 Application_BeginRequest方法中:
Thread.CurrentThread.CurrentCulture = new CultureInfo("zh-CN");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("zh-CN");
在WebApiModule的Initialize()方法裡面添加下麵代碼:
//跨域代碼 GlobalConfiguration.Configuration.EnableCors(new EnableCorsAttribute("*", "*", "*")); //Json時間格式化 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"; });
如果不起作用:
可以在實體類裡面:通過屬性賦值時強制轉換:
string creationTime; /// <summary> /// 創建時間 /// </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"); } }