Dev Helpers

React / Time and dates

Date input with ISO default

Dev Helpers · October 18, 2026

A date input expects a calendar date string. Be careful when converting the current instant because UTC and local dates can differ near midnight.

Worked example

// components/DateInputWithISODefault.tsx

export default function DateInputWithISODefault({
  iso = "2027-03-14T15:30:00Z",
}: { iso?: string } = {}) {
  return (
    <label>
      Event date <input type="date" defaultValue={iso.slice(0, 10)} />
    </label>
  );
}

Implementation notes

A defaultValue initializes an uncontrolled field. Later changes to the default do not automatically overwrite an edit the visitor has already made.

Try it yourself

Open the component near a timezone boundary and inspect the default.

Open the React example →

Editorial date October 18, 2026 · Published December 6, 2026

Related articles

Percentage meter

A percentage meter needs both a bounded visual fill and a meaningful textual value. Handle a zero denominator before dividing.

Vertical typesetting sample

Vertical typesetting changes the reading direction and available inline space. Treat the sample text as content so it remains selectable and accessible.

Square cover crop

A square image crop gives a card grid consistent geometry. The crop anchor determines whether the most important part of a photo survives.