I am using moment.js in one React native application.
In one component I am generating a calendar, with three days before and after today:
const cachedTime = new Date().getTime();
return [-2, -1, 0, 1, 2, 3, 4].map(val => {
const rowDate = new Date(cachedTime + 24 * 60 * 60 * val * 1000);
console.log(Moment(rowDate).format('YYYY-MM-DD'));
}
Maybe because of the time change it displays one day two times:
2020-10-23
2020-10-24
2020-10-25
2020-10-25
2020-10-26
2020-10-27
2020-10-28
How can I change this?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.