const [timeZone, setTimeZone] = useState("");
const [currentTime, setCurrentTime] = useState("");
const [timeUnloading, setTimeUnloading] = useState("");
const [timeGAP, setTimeGAP] = useState("");
const [zone, setZone] = useState("Chicago");
useEffect(() => {
setTimeZone(DateTime.local().setZone(`America/${zone}`));
const time = setInterval(() => {
console.log(1);
setCurrentTime(timeZone.toFormat("FF"));
setTimeUnloading(
timeZone.minus({ days: 8, hours: 12 }).toFormat("FF")
);
setTimeGAP(timeZone.minus({ days: 9 }).toFormat("FF"));
}, 1000);
return () => clearInterval(time);
}, []);
console.log(zone, timeZone, currentTime, timeUnloading, timeGAP);
Ошибка:
Uncaught TypeError: timeZone.toFormat is not a function