I have an app that posts to a firebase database. I am storing data such as the date created, id, description, etc. How can I figure the age of the posts in days using javascript?
Date Created:
$scope.products = [];
firebase.database().ref('products').orderByChild('rank').startAt(0).endAt(10000).limitToLast(10).once('value', function(products) {
products.forEach(function(product) {
var product = {
date: product.val().dateCreated,
id: product.key,
name: product.val().name
};
returns Sun May 21 2017 00:12:13 GMT-0500 (CDT)
and current date:
$scope.date = Date();
returns Wed May 31 2017 11:12:06 GMT-0500 (CDT)
Given the above, I want to output 10
from the difference in the dates . How should I proceed?
Thanks in advance