Registry / database / firestore-timestamp-formatter

firestore-timestamp-formatter

JSON →
library1.0.4jsnpmunverified

Firestore Timestamp Formatter (v1.0.4) converts Firestore Timestamp objects to JavaScript Date objects automatically using Firestore's withConverter method. It eliminates the need for manual toDate() calls on each document field. The package is simple, focusing solely on timestamp conversion, and is compatible with any Firestore client library. It operates exclusively in the browser or Node.js environments that support Firestore.

npm install firestore-timestamp-formatter
INSTALL
IMPORT
SIG · FIRESTORE-TIMESTAM
F
firestore-timestamp-formatter
databasejavascriptv1.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TimestampConverter
✓ import TimestampConverter from 'firestore-timestamp-formatter';
✗ const TimestampConverter = require('firestore-timestamp-formatter');
The package exports a default converter object. Use ESM import as shown.
TimestampConverter (named import attempt)
✓ import TimestampConverter from 'firestore-timestamp-formatter';
✗ import { TimestampConverter } from 'firestore-timestamp-formatter';
The default export is the object itself; there is no named export. Using curly braces will result in undefined.
TypeScript types
✓ import TimestampConverter from 'firestore-timestamp-formatter';
The package does not ship TypeScript definitions. You may need to declare a module or use @types if available.

Fetch a Firestore document with automatic timestamp-to-Date conversion using withConverter.

import { initializeApp } from 'firebase/app'; import { getFirestore, doc, getDoc } from 'firebase/firestore'; import TimestampConverter from 'firestore-timestamp-formatter'; const firebaseConfig = { /* your config */ }; const app = initializeApp(firebaseConfig); const db = getFirestore(app); const docRef = doc(db, 'users', 'user123'); const docSnap = await getDoc(docRef.withConverter(TimestampConverter)); if (docSnap.exists()) { const data = docSnap.data(); console.log(data.createdAt); // Date object } else { console.log('No such document!'); }
Debug
Known issues
gotchaOnly top-level Timestamp fields are converted; nested objects or arrays containing Timestamps are not converted.
fix
Manually convert nested Timestamps using toDate() or apply the converter recursively.
affects: >=1.0.0
gotchaThe converter only handles Firestore Timestamp objects; it does not convert other Firestore types like GeoPoint or Reference.
fix
Use a more comprehensive converter if you need to convert other types.
affects: >=1.0.0
deprecatedPackage has not been updated in over 2 years; no compatibility guarantee with newer Firestore versions.
fix
Consider using built-in Firestore conversion mechanisms or a community-maintained alternative.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'seconds')
The converter expects a Firestore Timestamp object at the field, but the field is missing or null.
fix
Ensure all timestamp fields exist in the document or add a null check before using the converter.
FirebaseError: Function withConverter() requires a valid FirestoreDataConverter.
The import may be incorrect or the converter object is undefined.
fix
Use default import: import TimestampConverter from 'firestore-timestamp-formatter';
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
firestore-timestamp-formatter — npm install firestore-timestamp-formatter · libregistry