Я пытался создать компонент календаря, но в моем бэкэнде Jason Api дата указана в метке времени. Так как же я собираюсь преобразовать метку времени в дату и время (с часовым поясом)?
Рассмотрим код ниже.
const appointments = [
{
id: 0,
title: 'Watercolor Landscape',
startDate: new Intl.DateTimeFormat('en-US').format(1585640511000), // here to convert timestamp
endDate: new Date(2018, 6, 23, 11, 30),
ownerId: 1,
}
];
constructor(props) {
super(props);
this.state = {
data: appointments,
};
this.commitChanges = this.commitChanges.bind(this);
}
render() {
const { data } = this.state;
console.log( data) // I console the data
return (
<Paper>
<Scheduler
data={data}
>
)
}
и вот результат с моей консоли:
![enter image description here](https://i.stack.imgur.com/ALKEJ.png)
Мой вопрос заключается в том, как преобразовать тип startDate так же, как endDate?