Currently in my local. The API is expecting the same formart as in SQL Server database which is yyyy-mm-dd.
However when i am deploying the application into production server. The API is expecting the datetime format as yyyy-dd-mm.
Is there any way to configure my .net core web api to accept yyyy-mm-dd as default format in every enviroment?
Please show some code. You can try the following in the AddJsonOptions()
pipeline in 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.
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With