# convert-firebase-timestamp

> Convert Firebase timestamps to js native date in fetched object

Latest version **0.0.5** (published 2022-09-12) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install convert-firebase-timestamp
pnpm add convert-firebase-timestamp
yarn add convert-firebase-timestamp
bun add convert-firebase-timestamp
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2022-09-12 |
| First published | 2020-05-20 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 11 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Peter Kracik |
| Maintainers | hatto |
| Keywords | firebase, timestamp, convert-date-format, date |

## Links

- npm: https://www.npmjs.com/package/convert-firebase-timestamp
- Repository: https://github.com/peterkracik/convert-firebase-timestamp
- Homepage: https://github.com/peterkracik/convert-firebase-timestamp#readme
- Issues: https://github.com/peterkracik/convert-firebase-timestamp/issues
- npm.io page: https://npm.io/package/convert-firebase-timestamp

## Dependencies (1)

- [rxjs](https://npm.io/package/rxjs.md) ^6.5.5

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 0.0.5 (latest) — 2022-09-12
- 0.0.4 — 2020-05-20
- 0.0.3 — 2020-05-20
- 0.0.2 — 2020-05-20
- 0.0.1 — 2020-05-20

## README

# Convert firebase timestamps

Script that converts firebase timestamp values to the JS date format

* converts each timestamp within a document (object), also inside its maps and array
* converts single value
* possible to call in rxjs pipe

## How to use

**document**

```typescript
 return this.db.collection('my-collection').doc(id).snapshotChanges().pipe(
    map(doc => convertTimestamps(doc.payload.data())
)
```

**single value**

```typescript
return this.db.collection('my-collection').doc(id).snapshotChanges().pipe(
    map(doc => {
		const data = doc.payload.data();
		data.date = convertTimestamp(data.date);
		return data;
	})
)
```
**in pipe**
! don't call it before map, the original document is too large to be convert and it will throw recursion exception

```typescript
return this.db.collection('my-collection').doc(id)
  .snapshotChanges().pipe(
        map(doc => doc.payload.data()),
        convertTimestampsPipe(),
    );
)
```

---
_Source: https://npm.io/package/convert-firebase-timestamp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
