There is an issue with doing it like described above, in that there is no compensation for time zone differences.
Time in a Memento field is kept in milliseconds UTC. Now() will return milliseconds in UTC, converted into local time. For example, in my time zone (Pacific, or UTC-8) comparing the time difference when in the evening to a date early the next day will result in a difference of 0, since both times will be on the same day when converted to UTC. Always compensating for the local time zone prevents this. (BTW - Date only fields in Memento may contain the time of day, even if the time is not being used.)
I use the following Javascript function to calculate the number of days, local time, a given date is from Jan 1, 1970. I will do it for both days, then just subtract those numbers to get the number of days:
function DayNumber(dt) {
// Returns the day number (count of days)
// from Jan 1, 1970. Negative for dates
// before then. DT is a Javascript Date Object
var curr = dt.getTime();
var curr = Math.floor(curr/60000);
curr = curr - dt.getTimezoneOffset();
curr = Math.floor(curr/1440);
return curr;
}
Example code to get the number of days from now for another Memento Date field:
var e = entry(); // Get pointer to current Memento entry
var dt = new Date(); // Returns current time and date
var itoday = DayNumber(dt); // Todays day count
var dtcalc = new Date(e.field("DateField")); // Memento field containing the date to compare
var icalc = DayNumber(dtcalc); // Get date day count
var iDiff = icalc - itoday; // Difference