You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{NTPClient}from'@hixbe/time';constclient=newNTPClient();consttime=awaitclient.getTime();console.log(time);// Date object
Check System Clock Accuracy
import{NTPClient}from'@hixbe/time';constclient=newNTPClient();constoffsetMs=awaitclient.getOffset();if(Math.abs(offsetMs)>500){console.warn(`⚠️ Your system clock is off by ${offsetMs}ms`);}else{console.log(`✅ Your system clock is accurate (±${Math.abs(offsetMs)}ms)`);}
import{NTPClient}from'@hixbe/time';asyncfunctionsyncClock(){try{constclient=newNTPClient();constoffsetMs=awaitclient.getOffset();console.log(`[${newDate().toISOString()}] Offset: ${offsetMs}ms`);if(Math.abs(offsetMs)>2000){console.warn('Large offset detected!');// Could trigger system time adjustment here}}catch(error){console.error('Sync failed:',error);}}// Sync every 60 secondssetInterval(syncClock,60*1000);