I have an editable kendo grid in which I have a date field. When I choose a date through the calendar for example: 26.12.2021 on post the model binder parses the date correctly.
If I manually enter the date in the cell the model binder parses the date as it was not an UTC and since my time zone is +2h it comes in the controller as 25.12.2021 22:00
(see the attached files)
Inside my startup.cs I have defined JsonOptions like this:
.AddNewtonsoftJson(options =>
{
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
});
In the Configure method:
var supportedCultures = new[] { new CultureInfo("bg-BG") };
app.UseRequestLocalization(new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("bg-BG"),
SupportedCultures = supportedCultures,
SupportedUICultures = supportedCultures
});
Layout.cshtml
<script src="~/lib/kendo/js/cultures/kendo.culture.bg-BG.min.js"></script>
<script>
kendo.culture("bg-BG");
</script>