> Lucky for you I've been working on that for my family tree vertical.
> Unfortunately only giving amount of months and years (not days).
> The code is below - hope this is a good starting point.
Here's some other code that also calculates days (approximated using
average of 30.4 days/month):
var now=new Date();
var then=new Date(prompt('enter a date',"1/1/2009"));
var age=now.getTime()-then.getTime();
var hs=3600000; var ds=24*hs; var ms=30.4*ds; var ys=365*ds;
var y=Math.floor(age/ys);
var m=Math.floor((age-y*ys)/ms);
var d=Math.floor((age-y*ys-m*ms)/ds)+1;
return '%0 years, %1 months, %2 days'.format([y,m,d]);
enjoy,
-e
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/tiddlywiki?hl=en
-~----------~----~----~----~------~----~------~--~---