491 B
Executable File
491 B
Executable File
Timestamps with getTime()
Date.getTime() returns a timestamp in milliseconds since Unix epoch.
Example
const startTime = start.getTime();
Why this is useful
Numeric timestamps are easy to compare:
startTime >= rangeStart
startTime <= rangeEnd
Comparing numbers is usually simpler and safer than comparing date strings directly.
Python comparison
start_ts_ms = int(start_dt.timestamp() * 1000)
Both represent an absolute moment in time.