Issue Bug Under Review

#111420Admin Panel: "Simulate time" date/time fields show 1970-01-01 00:00 when no simulation is set

Grischa Schüring 11/12/26, 10:49 updated 11/13/26, 09:05

Description

Steps to reproduce

  1. Enable the admin panel (config.admPanel = 1, user TSconfig admPanel.enable.preview = 1).
  2. Log in to the backend and open a frontend page.
  3. Open the admin panel, open the “Preview” settings. No time simulation is active (checkbox “Simulate time” unchecked).

Expected

The (disabled) date and time fields are empty.

Actual

The date field shows 01/01/1970 and the time field 00:00.

If the user ticks “Simulate time” and saves without changing the date, the result depends on the browser timezone. In a browser east of UTC (e.g. Europe/Berlin) the fields are parsed as local time, which gives a negative timestamp (-3600). PreviewModule clamps it via max($simulateDate, 60), so the frontend is rendered at 1970-01-01 00:01 UTC. All records with a starttime disappear, which is confusing. In a browser running in UTC the value becomes 0 and no simulation happens at all.

Cause

Without a simulation, PreviewModule::getPageSettings() passes (int)($this->config['simulateDate'] ?? 0), i.e. 0, to the template. Partials/Form/DateTime.fluid.html renders it into the hidden field:

<input type="hidden" name="TSFE_ADMIN_PANEL[{name}]" id="{name}" value="{value}" />

Build/Sources/TypeScript/adminpanel/modules/preview.ts only checks whether the hidden field has a value. The string “0” is truthy, so it initialises the pickers with the Unix epoch:

if (this.targetField.value) {
  const initialDate = new Date(parseInt(this.targetField.value, 10) * 1000);
  this.dateField.valueAsDate = initialDate;
  this.timeField.valueAsDate = initialDate;
}

Possible fix

Treat 0 as “no value”, e.g. in preview.ts:

const initialTimestamp = parseInt(this.targetField.value, 10);
if (initialTimestamp > 0) {
  ...
}

or render an empty value in the partial: value="{f:if(condition: value, then: value)}".

Environment

  • Reproduced with TYPO3 13.4.39 (Composer mode), PHP 8.4.
  • The code is unchanged on main (v14).
  • Related, but a different issue: #101849 (simulated time does not respect the timezone). valueAsDate interprets the timestamp as UTC, while updateDateField() parses the entered values as local time.

Reviews 1

History 12