Home > Software design >  How would I convert iso dateformat to timestamp using firebase admin
How would I convert iso dateformat to timestamp using firebase admin

Time:07-30

How would I convert the following dateformat 2020-09-18T18:36:15.000Z to Timestamp using the firebase-admin npm package

CodePudding user response:

You can just use the fromDate function like this:

import * as admin from 'firebase-admin';

const str = "2020-09-18T18:36:15.000Z";
const timestamp = admin.firestore.Timestamp.fromDate(new Date(str))

Check the documentation for further readings here.

  • Related