dayjs
dayjs copied to clipboard
Dayjs doesn't render a date with a timezone
trafficstars
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.
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 (
<div>
{dayjs.tz("2013-11-18 11:55:20", "America/Toronto")}
</div>
);
}
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
I think you need to add the .format() part.
https://day.js.org/docs/en/display/format