Topic: An all day calendar appointment moves back a day for remote staff
monoStudio42
free
asked 1 week ago
Our API sends an all day appointment as the date string 2026-11-16. It displays on the expected day in our office, but a colleague in a timezone west of UTC sees it on the previous day. Timed appointments with an explicit offset display correctly.
The mapping currently passes every date through new Date(apiValue), including these date-only values. The business rule is that an all day appointment should stay on the same calendar date for everyone. How should we distinguish it from a timed appointment?
Arkadiusz Idzikowski
staff
answered 1 week ago
Treat an all day business date separately from a timestamp. Parsing a YYYY-MM-DD string with the Date constructor represents UTC midnight, which can become the previous local date when displayed west of UTC.
Keep the date-only value in the API model and map its year, month and day to the local calendar date expected by your calendar input. Continue preserving the explicit offset for timed appointments. The example below handles your controlled date-only format; validate incoming values before using it with arbitrary data.
const [year, month, day] = dateOnly.split('-').map(Number);
const localCalendarDate = new Date(year, month - 1, day);
https://mdbootstrap.com/docs/angular/plugins/calendar/
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Free
- Premium support: No
- Technology: MDB Angular
- MDB Version: MDB5 9.1.0
- Device: Desktop
- Browser: Edge
- OS: Windows 11
- Provided sample code: No
- Provided link: No