Skip to content

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

Closed as not planned

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)

Activity

  1. github-actions commented on Jun 2, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If your issue is distinct from these, please clarify what is different. Otherwise, consider adding your input to one of the existing issues.

  2. v4ever1luv commented on Jun 2, 2026

    @v4ever1luv
    Author

    This issue is distinct from #22781 and #9025 in that it covers 3 areas, not just session titles:

    1. Session title (session.ts) - same as [FEATURE]: Default session title should use local time instead of UTC (Z) #22781
    2. Log filenames (util/log.ts) - same as fix(opencode): log timestamps use local datetime instead of UTC ISO string #21330, still unfixed
    3. Message timestamps in TUI (/timestamps command) - currently bugged per /timestamps command has no visible effect and /exit missing from autocomplete #26625

    I'm working on a PR that addresses all 3 with a unified local-time formatter. Will link it here shortly.

  3. v4ever1luv commented on Jun 2, 2026

    @v4ever1luv
    Author

    Created PR #30350 that fixes this issue by replacing toISOString() with local-time formatting in session.ts, log.ts, and trace.ts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions