Prakash Bharti
Prakash Bharti

Reputation: 341

How to use firestore TIMESTAMP to create time-stamp in JavaScript

i am getting the data like this October 17, 2017 at 5:47:37 PM UTC+5:30 Now, how can i convert it to timestamp like 55773**998 ?

Upvotes: 2

Views: 3253

Answers (2)

Milton
Milton

Reputation: 968

First, you need to import the Firebase Admin:

const admin = require('firebase-admin');

Then save the Firestore timestamp:

const timestamp = admin.firestore.FieldValue.serverTimestamp();

Upvotes: 3

void
void

Reputation: 36703

You can remove at and then convert it to new date.

var date = " October 17, 2017 at 5:47:37 PM UTC+5:30";
var parsedDate = new Date(date.replace(/at/g, "")).getTime();
console.log(parsedDate);

Upvotes: 3

Related Questions