Skip to content

fix: session timestamps and log filenames use UTC (toISOString()) instead of local time #30347

@v4ever1luv

Description

@v4ever1luv

Describe the bug

Session titles and log filenames use
ew Date().toISOString(), which always returns UTC time. On systems with non-UTC timezones (e.g. UTC+07:00), timestamps are displayed 7 hours off from local time, causing confusion when users try to identify sessions or correlate logs with local events.

Steps to reproduce

  1. Open opencode TUI (v1.15.13) on Windows with timezone UTC+07:00 (SE Asia Standard Time)
  2. Start a new session — title shows \New session - 2026-06-01T17:00:00.000Z\ instead of local \2026-06-02T00:00:00\
  3. Enable /timestamps\ — message timestamps also display in UTC
  4. Check log files in ~/.local/share/opencode/logs/\ — filenames use UTC timestamps

Expected behavior

Session titles, message timestamps, and log filenames should reflect the system's local timezone, not UTC.

Actual behavior

All timestamps are hardcoded to UTC via
ew Date().toISOString().

Root cause locations

Two source files use \ oISOString():

  1. *\packages/opencode/src/session/session.ts* — session title generation
  2. *\packages/opencode/src/util/log.ts* — log filenames and log entry timestamps

\ oISOString()\ is defined by ECMAScript to always return UTC (ending in \Z), ignoring the system \TZ\ environment variable.

Proposed fix

Replace \ oISOString()\ with a local-time-aware formatter:

\\ ypescript
function toISOLocal(d: Date): string {
const z = (n: number) => String(n).padStart(2, '0');
const off = d.getTimezoneOffset();
const sign = off > 0 ? '-' : '+';
const absOff = Math.abs(off);
return \--\T::\:\;
}
\\

Or alternatively, use \Intl.DateTimeFormat\ or a library like \date-fns/\dayjs\ for more robust formatting.

Related issues

Environment

  • OpenCode version: v1.15.13
  • Platform: Windows
  • Timezone: UTC+07:00 (SE Asia Standard Time)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions