Can't save local date with datepicker.
I am using material's datepicker. When I select date, everything is ok, but after passing it to the server I get the previous day, that is 4 hours before, my time zone is UTC + 4. How can I make it not to subtract 4 hours?
Try using string instead of datetime in backend
I have the same problem and I found a solution from here: https://material.angular.io/components/datepicker/overview#choosing-a-date-implementation-and-date-format-settings
I added the following code to the module providers and then it works.
providers: [
{ provide: MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: { useUtc: true } }
]
The datepicker returns Date instances (or Moment instances if using the moment date adapter). It's up to you to decide how these are stringified and stored in your backend.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.