net core 3.1 mvc web app. On my server I do:
[HttpGet]
public IActionResult LastDate()
{
DateTime send = DateTime.Now;
try
{
send = _db.MySend.ToList().Max(x => x.Date).GetValueOrDefault().AddDays(1);
}
catch { }
return Json( new { date = send });
}
then on my Front-end I do:
var link = 'MYLINK';
var args = {};
$.ajax({
type: "GET",
url: link,
data: args,
dataType: "json",
success: function (data) {
var my_date = data.date;
document.getElementById('Dateee').value = my_date;
},
error: function () {
alert("Error.");
return;
}
});
I have tried to convert Json date to Javascript but I am unable. Thanks for any help.
EDIT: 1. I am using Microsoft.AspNetCore.Mvc Json. 2. My localization that affects date:
var supportedCultures = new[]{
new CultureInfo("cs-CZ")
};
app.UseRequestLocalization(new RequestLocalizationOptions
{
DefaultRequestCulture = new Microsoft.AspNetCore.Localization.RequestCulture("cs-CZ"),
SupportedCultures = supportedCultures,
FallBackToParentCultures = false
});
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture("cs-CZ");```