xxxxxxxxxx
// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
long millis = System.currentTimeMillis();
Timestamp timestamp =
Timestamp.newBuilder()
.setSeconds(millis / 1000)
.setNanos((int)(millis % 1000 * 1_000_000))
.build();
xxxxxxxxxx
import firebase from 'firebase';
{
timestamp: firebase.firestore.FieldValue.serverTimestamp(),
}
xxxxxxxxxx
// Reference to your Firestore collection
const collectionRef = firebase.firestore().collection('yourCollection');
// Add a new document with the server timestamp
collectionRef.add({
data: 'Your data',
timestamp: firebase.firestore.FieldValue.serverTimestamp()
})
.then((docRef) => {
console.log('Document written with ID: ', docRef.id);
})
.catch((error) => {
console.error('Error adding document: ', error);
});
xxxxxxxxxx
import moment from 'moment';
// store data
const storeData = {
dataWithMoment: moment(values.dateOfDispatch, "MM-DD-YYYY Z").valueOf(),
dateWithPureJs: moment("03-25-2015 +0000", "MM-DD-YYYY Z").valueOf()
}
// retrive data
function getOne(item) {
return
}