Converti timestamp Unix in data leggibile e viceversa β aggiornamento in tempo realeConvert Unix timestamps to readable dates and back β real-time updates
Il timestamp Unix (o Epoch time) Γ¨ il numero di secondi trascorsi dal 1Β° gennaio 1970 alle 00:00:00 UTC. JavaScript usa millisecondi (Date.now()), Firebase RTDB usa millisecondi, mentre molte API usano secondi. Capire quale unitΓ si sta usando Γ¨ fondamentale per evitare bug di 1000x.
Per riconoscere il formato: un timestamp di 10 cifre Γ¨ in secondi (es. 1750000000), uno di 13 cifre Γ¨ in millisecondi (1750000000000). Questo converter rileva automaticamente il formato.
The Unix timestamp (or Epoch time) is the number of seconds elapsed since January 1, 1970 00:00:00 UTC. JavaScript uses milliseconds (Date.now()), Firebase RTDB uses milliseconds, while many APIs use seconds. Knowing which unit you're using is key to avoiding 1000x bugs.
To recognize the format: a 10-digit timestamp is in seconds (e.g. 1750000000), a 13-digit one is in milliseconds (1750000000000). This converter automatically detects the format.
Come Firebase gestisce i timestamp?How does Firebase handle timestamps?
Firebase RTDB e Firestore usano approcci diversi. RTDB usa firebase.database.ServerValue.TIMESTAMP che salva millisecondi Unix. Firestore usa firebase.firestore.FieldValue.serverTimestamp() che produce un oggetto Timestamp con metodi .toDate() e .toMillis().Firebase RTDB and Firestore use different approaches. RTDB uses firebase.database.ServerValue.TIMESTAMP which stores Unix milliseconds. Firestore uses firebase.firestore.FieldValue.serverTimestamp() which produces a Timestamp object with .toDate() and .toMillis() methods.