On this page

Function now

  • Returns the current time in milliseconds. When time is frozen via setNow(), returns the frozen timestamp. Otherwise returns real browser time via performance.now().

    Returns number

    Current time in milliseconds

    // Measure elapsed time
    const start = maplibregl.now();
    // ... later ...
    const elapsed = maplibregl.now() - start;
    
    // During frozen time
    maplibregl.setNow(16.67);
    console.log(maplibregl.now()); // 16.67
    maplibregl.restoreNow();
    console.log(maplibregl.now()); // real time
    
Was this helpful?
SDK JS
Reference
now