O
O
OcelotJungle2021-02-10 07:08:48
JavaScript
OcelotJungle, 2021-02-10 07:08:48

Wrong display of dates in react-big-calendar, why?

Import calendar and moment.js:

import { Calendar, momentLocalizer } from "react-big-calendar";
import moment from "moment";


I create a localizer and a list of events, output to the console to check the values:
const localizer = momentLocalizer(moment);
const events = [
  {
    title: "1",
    start: moment().toDate(),
    end: moment().add(1, "days").toDate()
  },
  {
    title: "2",
    start: moment().add(1, "days").toDate(),
    end: moment().add(2, "days").toDate()
  },
  {
    title: "3",
    start: moment().add(2, "days").toDate(),
    end: moment().add(3, "days").toDate()
  },
];
console.log(events);


I create a calendar:
return <Calendar localizer={localizer} events={events} views={["month"]} />;


Everything is in order, the dates are correct:
spoiler
x6vLBZ_9CVE.jpg?size=1251x120&quality=96&proxy=1&sign=130b57b44bd68f28e54713aeccc8beec&type=album


But the calendar doesn't think so:
spoiler
7ld7IKn3kng.jpg?size=995x458&quality=96&proxy=1&sign=ea28faed65b7b43b6dd983e22da9ecc4&type=album


I tried to install the version of the calendar and the last one - 0.31.0, and the previous one - 0.30.0, and six months ago - 0.27.0, there is no effect. Accordingly, the real list of events that I tried to transmit is displayed incorrectly.
Can anyone suggest what I'm doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2021-02-10
@OcelotJungle

Can't reproduce your problem. https://codesandbox.io/s/qna-q936059-uonwv

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question