Angular: the backend saves the wrong date

In the database is saved a date different from the date of the datepicker

This error is frequent when the date is passed to the backend via REST api.

When we are using a timezone defined time this one is converted by the REST service and the data saved in the backend differs 1 day from the date used in the frontend.

A simple approach to remove the issue is to convert the date in the frontend, e.g. using moment.js:

dateUsedInTheCode.format('yyyy-MM-DD') this removes the timezone and it avoids format errors.

You could be interested in

Angular common error messages

Angular message errors ... again this one ... how did I solve last time?

Enums in Angular templates

How to use enum in the html template

Super fast WebApp built by Marco using SpringBoot 3 and Java 17 hosted in Switzerland