Slight optimization: use Date.now() instead of (new Date()).getTime().
This avoids creating a new date object that is discarded immediately.