Timestamp with a time but no timezone shows as 1 January 1970

Open Beginner friendly
#43,637 6 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@Sarthak-agrawal-tech is already working on this.

Since Nov 11, 2026.

  • #43651 by @Sarthak-agrawal-tech — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
backend

Research direction

The issue identifies packages/message-parser, grammar.pegjs, src/utils.ts, and the timestamp tests. Start by reading timestampFromHours alongside timestampFromIsoTime and check how the grammar passes a missing timezone. Add coverage for time-only forms without a timezone, then run the message parser tests and confirm those forms resolve to today at the requested time.

Written by the indexing model from the issue text.

Description

type: bug
Description:

A timestamp with only a time and no timezone, like <t:10:30>, shows as 1 January 1970 instead of today at 10:30.

Steps to reproduce:
  1. Send a message with <t:10:30> (or <t:10:30:00:t>).
  2. Or parse it directly with @rocket.chat/message-parser.
Expected behavior:

The timestamp is today at 10:30.

Actual behavior:

The parser returns timestamp "0", which is 1 January 1970:

"<t:10:30>" => [{"type":"PARAGRAPH","value":[{"type":"TIMESTAMP","value":{"timestamp":"0","format":"t"},"fallback":[0,9]}]}]
Server Setup Information:

Found in packages/message-parser on develop, not on a running server.

Additional context

When no timezone is given, the grammar passes null (tz:Timezone? in grammar.pegjs, lines 136 and 138). timestampFromHours in src/utils.ts has timezone = '', but that default only applies to undefined, not null. So the date string ends in ...T10:30:00null, which is an invalid date, and NaN | 0 gives 0.

timestampFromIsoTime just below already handles this with timezone ? timezone : '', so <t:2026-11-01T10:00:00:f> works. The tests only cover time forms with a timezone, like <t:10:00+00:00>.

The open PR #41752 changes the same line but keeps the null, so with it the result would be "NaN" instead of "0".

Dominant language
TypeScript
Stars
46.5k
Forks
14.1k
Avg merge
1d 21h
Merged PRs (30d)
381

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from RocketChat/Rocket.Chat

All issues in RocketChat/Rocket.Chat

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.