iamkun / iamkun/dayjs

Dayjs doesn't render a date with a timezone

Open
#2,058 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
Dayjs doesn't render a date with a timezone. The following code returns this error:

> Objects are not valid as a React child (found: object with keys {$L, $d, $x, $y, $M, $D, $W, $H, $m, $s, $ms, $offset}). If you meant to render a collection of children, use an array instead.

```js
import React from "react";
import dayjs from "dayjs";
import timezone from 'dayjs/plugin/timezone'
import utc from 'dayjs/plugin/utc'

dayjs.extend(utc)
dayjs.extend(timezone)

export default function App() {
return (


{dayjs.tz("2013-11-18 11:55:20", "America/Toronto")}

);
}
```

I've simply followed the example on your doc: https://day.js.org/docs/en/timezone/timezone

**Expected behavior**
A clear and concise description of what you expected to happen.

**Information**
- Day.js Version 1.11.15
- OS: OSX
- Browser Chrome 104.0.5112.101

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the supplied React example using dayjs.tz with the utc and timezone plugins, then compare its behavior with the timezone documentation example. Determine whether the documented entry point should be directly renderable and define completion as a confirmed fix or a clarified example with regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.