p5.js Date object and millis() synchronization across regional time zones
0 reputation · 31 Oct 2023, 09:18 UTC
p5.js utilizes the JavaScript Date object for absolute time tracking and the millis() function for elapsed time since the sketch began. While millis() provides a consistent internal clock independent of the system's regional settings, the Date object is subject to the host environment's local time zone.
When developing time-dependent animations or data visualizations that rely on both absolute timestamps and relative elapsed time, there is a discrepancy in how these two values behave during system clock adjustments, such as Daylight Saving Time (DST) shifts or NTP synchronizations.
What is the recommended approach for maintaining synchronization between the relative millis() counter and localized Date objects to ensure consistent behavior across different global regions?
- How should developers handle the potential drift between the system clock and the sketch's internal timer?
- Is there a native method to normalize
Dateoutputs to a specific time zone without external libraries?