I am developing a project with Angular and ASP.NET Core. I am sending this date from Angular to ASP.NET Core.
Date object from Angular:
<code>2024-12-21T00:00:00
</code>
<code>2024-12-21T00:00:00
</code>
2024-12-21T00:00:00
But when reading it in ASP.NET Core, it will look like this:
<code>2024-12-20T18:30:00
</code>
<code>2024-12-20T18:30:00
</code>
2024-12-20T18:30:00
How can I get rid of adding offsets for the date object when sending it from Angular frontend?
Thanks in advance.
6
Please try the below code:
<code> const currentDate = new Date();
const formattedDate = currentDate.toLocaleDateString('en-CA');
console.log(formattedDate);
</code>
<code> const currentDate = new Date();
const formattedDate = currentDate.toLocaleDateString('en-CA');
console.log(formattedDate);
</code>
const currentDate = new Date();
const formattedDate = currentDate.toLocaleDateString('en-CA');
console.log(formattedDate);