Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

firebase timestamp to date angular

import { firestore } from 'firebase/app';
import Timestamp = firestore.Timestamp;

@Injectable()
export class YourService {

....

    list = (): Observable<any[]> => this.collection
        .snapshotChanges()
        .pipe(
            map(changes => {
                return changes.map(a => {
                    const data = a.payload.doc.data() as any;
                    Object.keys(data).filter(key => data[key] instanceof Timestamp)
                        .forEach(key => data[key] = data[key].toDate())
                    data._id = a.payload.doc.id;
                    return data;
                });
            })
        );

...
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: aos initial configuration vue 
Javascript :: filter by keyname javascript 
Javascript :: Group array of strings by first letter 
Javascript :: switch case in javascript 
Javascript :: emailjs react npm 
Javascript :: how to assign value to variable 
Javascript :: bootstrap dropdown doesnt work with angular 12 
Javascript :: updateone mongoose example 
Javascript :: on() jquery 
Javascript :: discord.js emoji in embed 
Javascript :: javascript check if object 
Javascript :: get bottom position of element javascript 
Javascript :: how to add field to object in js 
Javascript :: remove specific element from array javascript 
Javascript :: flutter json to class 
Javascript :: how to search for a voice channel within a guild using discord.js 
Javascript :: javascript get day 
Javascript :: how to flip a Number in javascript 
Javascript :: round decimal js 
Javascript :: js hide div 
Javascript :: short ajax get method jquery 
Javascript :: JavaScript read as Json 
Javascript :: input event on value changed 
Javascript :: string to json nodejs 
Javascript :: react router get data from url 
Javascript :: jquery change position animate 
Javascript :: tolocalestring javascript currency fixing 2 decimal places 
Javascript :: font awesome cdn svg with js 
Javascript :: define an unsigned long int js 
Javascript :: @babel/plugin-proposal-optional-chaining 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =