Hey guys,
I need some help changing the time displayed by the CesiumJS clock.
I’m using React 19.1.0 and Cesium 1.130.0.
Basically, I have a Viewer component that passes the onReady prop to a function called handleViewerReady, where I try to adjust the time zone to Chile (UTC-3).
Here’s a simplified version of my code:
<Viewer
ref={viewerRef}
full
baseLayerPicker={false}
geocoder={false}
navigationInstructionsInitiallyVisible={false}
selectionIndicator={true}
infoBox={false}
animation={timeLine}
timeline={timeLine}
homeButton={false}
navigationHelpButton={false}
shouldAnimate={true}
onReady={handleViewerReady}
>
And here’s the function:
function handleViewerReady(viewer) {
const now = new Date();
const start = JulianDate.addHours(JulianDate.fromDate(now), -3);
const stop = JulianDate.addHours(start, 1, new JulianDate());
viewer.clock.startTime = start;
viewer.clock.currentTime = start;
viewer.clock.stopTime = stop;
viewer.clock.clockRange = ClockRange.LOOP_STOP;
viewer.clock.clockStep = ClockStep.SYSTEM_CLOCK;
viewer.clock.multiplier = 1;
viewer.clock.shouldAnimate = true;
viewer.timeline.zoomTo(start, stop);
}
This function gets the current date and tries to shift it to UTC-3, but the time shown in Cesium doesn’t seem to match what I expect.
I’m not sure if this is the right way to handle local time zones in Cesium, or if I need to use a different approach with JulianDate or Clock.
Any ideas on how to correctly set the clock to show Chile’s local time (UTC-3)?
Thanks in advance!
