Advertisement
dhniceday

Untitled

Nov 26th, 2022
714
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ---
  2. birthday: 1975-05-26
  3. ---
  4.  
  5. ```dataviewjs
  6. const today = dv.func.date('today');
  7. const birthday = dv.current().birthday;
  8.  
  9. function difference(d1, d2) {
  10.   var m = moment(d1);
  11.   var years = m.diff(d2, 'years');
  12.   m.add(-years, 'years');
  13.   var months = m.diff(d2, 'months');
  14.   m.add(-months, 'months');
  15.   var days = m.diff(d2, 'days');
  16.  
  17.   return {years: years, months: months, days: days};
  18. }
  19.  
  20. y = difference(Date.parse(today), Date.parse(birthday));
  21. dv.span(y)
  22. ```
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement