Skip to content

fix: date-only column display shifted one day behind in non-UTC timezones - #2882

Open
tareko wants to merge 1 commit into
nextcloud:mainfrom
tareko:fix/date-display-timezone-shift
Open

fix: date-only column display shifted one day behind in non-UTC timezones#2882
tareko wants to merge 1 commit into
nextcloud:mainfrom
tareko:fix/date-display-timezone-shift

Conversation

@tareko

@tareko tareko commented Aug 9, 2026

Copy link
Copy Markdown

Bug

The discovery of this bug and code to fix it were assisted by AI: GLM 5.2

Date-only columns display the date one day behind the entered value for users in timezones behind UTC (e.g. America/Toronto UTC-4).

Steps to reproduce:

  1. Create a date-only column (not datetime, just date)
  2. Enter a date (e.g. 2025-08-25)
  3. The table view shows the previous day (e.g. Aug 24, 2025)
  4. Clicking to edit shows the correct date — the bug is only in the display

Root cause

In datetimeDate.js, formatValue parsed date-only values (e.g. "2025-08-25") using the datetime format 'YYYY-MM-DD HH:mm:ss':

formatValue(value) {
    return Moment(value, 'YYYY-MM-DD HH:mm:ss').format('ll')
}

Since the input string doesn't match the format (no time component), Moment.js falls back to ISO 8601 parsing, which interprets date-only strings as UTC midnight. When .format('ll') then converts to the user's local timezone, the date shifts back one day for users behind UTC.

Fix

Use 'YYYY-MM-DD' as the Moment parse format — this matches the actual stored value format and ensures local-timezone parsing:

formatValue(value) {
    return Moment(value, 'YYYY-MM-DD').format('ll')
}

This is consistent with getDateFormat() in TableCellDateTime.vue, which already uses 'YYYY-MM-DD' for the edit mode — explaining why editing showed the correct date while the cell display didn't.

Fixes #2705

@tareko
tareko requested review from blizzz and enjeck as code owners August 9, 2026 04:35
…ones

The formatValue method for datetime-date columns parsed date-only values
(e.g. "2025-08-25") using the datetime format 'YYYY-MM-DD HH:mm:ss'.
Since the input doesn't match the format, Moment.js falls back to ISO 8601
parsing, which interprets date-only strings as UTC midnight. When
.format('ll') then converts to the user's local timezone, the date shifts
back one day for users behind UTC (e.g. America/Toronto UTC-4).

Fix: use 'YYYY-MM-DD' as the Moment parse format, which matches the actual
value and ensures local-timezone parsing. This is consistent with
getDateFormat() in TableCellDateTime.vue, which already uses 'YYYY-MM-DD'
for the edit mode (and editing correctly showed the right date).

Fixes nextcloud#2705
Signed-off-by: Tarek <shopping@tarek.org>
Assisted-by: GLM:5.2
@tareko
tareko force-pushed the fix/date-display-timezone-shift branch from 3588be0 to 8be57c2 Compare August 9, 2026 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Viewing date in column 1 day off from date entered

1 participant