mok*_*223 2 .net-core asp.net-core-webapi asp.net-core-2.0
目前在我当地.API期望与SQL Server数据库中的结构相同,即yyyy-mm-dd.
但是,当我将应用程序部署到生产服务器时.API期望日期时间格式为yyyy-dd-mm.
有没有办法配置我的.net核心web api接受yyyy-mm-dd作为每个环境中的默认格式?
Fel*_*Too 12
请显示一些代码.您可以在AddJsonOpions()管道中尝试以下内容ConfigureServices()
services
.AddMvc()
.AddJsonOptions(options =>
{
//Set date configurations
//options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
options.SerializerSettings.DateFormatString = "yyyy-MM-dd"; // month must be capital. otherwise it gives minutes.
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7338 次 |
| 最近记录: |