UI5 OData V2 Date Is One Day Off: Cause and Fix

A date from OData V2 is one day off in UI5 because Edm.DateTime arrives as a JavaScript Date at midnight UTC. A browser west of UTC shows the previous evening. Use sap.ui.model.odata.type.DateTime with the constraint displayFormat: 'Date', which reads and writes the UTC day.
Fix the display
<Text text="{
path: 'DeliveryDate',
type: 'sap.ui.model.odata.type.DateTime',
formatOptions: { style: 'medium' },
constraints: { displayFormat: 'Date' }
}"/>
The constraint belongs under constraints, not under formatOptions.
See the difference
We formatted midnight UTC on 1 December 2026 with UI5 1.108.55 in two browser time zones:
| Type | New York | Istanbul |
|---|---|---|
OData DateTime, no constraint |
Nov 30, 2026, 7:00:00 PM | Dec 1, 2026, 3:00:00 AM |
sap.ui.model.type.Date |
Nov 30, 2026 | Dec 1, 2026 |
sap.ui.model.type.Date with UTC: true |
Dec 1, 2026 | Dec 1, 2026 |
OData DateTime, displayFormat: 'Date' |
Dec 1, 2026 | Dec 1, 2026 |
A developer in Istanbul does not see the display error. A user in New York does.
The opposite error when saving
East of UTC the problem appears when you write. new Date(2026, 11, 1) is local midnight. In Istanbul that is 2026-11-30T21:00:00.000Z, so a service that takes the UTC day stores 30 November.
Build the value from the local day before you set it:
function toUtcDay(local) {
return new Date(Date.UTC(
local.getFullYear(), local.getMonth(), local.getDate()
));
}
toUtcDay(new Date(2026, 11, 1)).toISOString();
// 2026-12-01T00:00:00.000Z in both time zones
If a control uses two-way binding with displayFormat: 'Date', the type does this for you: parsing Dec 1, 2026 returned 2026-12-01T00:00:00.000Z in both zones. Do not convert a second time.
Which type for which field
| OData type | UI5 type |
|---|---|
V2 Edm.DateTime, only a day |
odata.type.DateTime with displayFormat: 'Date' |
V2 Edm.DateTimeOffset |
odata.type.DateTimeOffset |
V4 Edm.Date |
odata.type.Date; the value is a string such as 2026-12-01 |
Test it in another time zone
Chrome DevTools can override the time zone: open More tools, then Sensors, and choose a location west and one east of UTC. Reload after each change. On the ABAP side, the day comes from the service, so also check the date conversion in your code.
Adding or removing hours by hand is not a fix: it breaks in other zones and when daylight saving time changes.
Sources: odata.type.DateTime API · odata.type.Date API